Skip to content

Commit

Permalink
proc: do not check sizes in not loadable sections
Browse files Browse the repository at this point in the history
JIRA: RTOS-912
  • Loading branch information
badochov committed Sep 25, 2024
1 parent 1f9ea40 commit f78a283
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions proc/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ static int process_validateElf32(void *iehdr, size_t size)
return -ENOEXEC;
}
for (i = 0; i < ehdr->e_phnum; i++) {
if ((phdr->p_type != PT_LOAD) &&
(process_isPtrValid(iehdr, size, ((char *)ehdr) + phdr[i].p_offset, phdr[i].p_filesz) == 0)) {
return -ENOEXEC;
if (phdr->p_type != PT_LOAD) {
if (process_isPtrValid(iehdr, size, ((char *)ehdr) + phdr[i].p_offset, phdr[i].p_filesz) == 0) {
return -ENOEXEC;
}
continue;
}

offs = phdr->p_offset & ~(phdr->p_align - 1);
Expand Down Expand Up @@ -432,9 +434,11 @@ static int process_validateElf64(void *iehdr, size_t size)
return -ENOEXEC;
}
for (i = 0; i < ehdr->e_phnum; i++) {
if ((phdr->p_type != PT_LOAD) &&
(process_isPtrValid(iehdr, size, ((char *)ehdr) + phdr[i].p_offset, phdr[i].p_filesz) == 0)) {
return -ENOEXEC;
if (phdr->p_type != PT_LOAD) {
if (process_isPtrValid(iehdr, size, ((char *)ehdr) + phdr[i].p_offset, phdr[i].p_filesz) == 0) {
return -ENOEXEC;
}
continue;
}

offs = phdr->p_offset & ~(phdr->p_align - 1);
Expand Down

0 comments on commit f78a283

Please sign in to comment.