diff options
author | kan <kan@FreeBSD.org> | 2002-10-23 01:57:39 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2002-10-23 01:57:39 +0000 |
commit | f8332b9941d10315befae96f8c4872ddc31e7f0f (patch) | |
tree | 8d3cc46063e6c1a396e499979e51829edef0b1a5 | |
parent | 3afac5a8ec1fc1a600ee4d70cf1f87b2183567e9 (diff) | |
download | FreeBSD-src-f8332b9941d10315befae96f8c4872ddc31e7f0f.zip FreeBSD-src-f8332b9941d10315befae96f8c4872ddc31e7f0f.tar.gz |
Handle binaries with arbitrary number PT_LOAD sections, not only
ones with one text and one data section.
The text and data rlimit checks still needs to be fixed to properly
accout for additional sections.
Reviewed by: peter (slightly different patch version)
-rw-r--r-- | sys/kern/imgact_elf.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 78b78a8..6f42df6 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -760,20 +760,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) data_addr = seg_addr; } total_size += seg_size; - - /* - * Check limits. It should be safe to check the - * limits after loading the segment since we do - * not actually fault in all the segment's pages. - */ - if (data_size > - imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur || - text_size > maxtsiz || - total_size > - imgp->proc->p_rlimit[RLIMIT_VMEM].rlim_cur) { - error = ENOMEM; - goto fail; - } break; case PT_PHDR: /* Program header table info */ proghdr = phdr[i].p_vaddr; @@ -782,6 +768,25 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) break; } } + + if (data_addr == 0 && data_size == 0) { + data_addr = text_addr; + data_size = text_size; + } + + /* + * Check limits. It should be safe to check the + * limits after loading the segments since we do + * not actually fault in all the segments pages. + */ + if (data_size > + imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur || + text_size > maxtsiz || + total_size > + imgp->proc->p_rlimit[RLIMIT_VMEM].rlim_cur) { + error = ENOMEM; + goto fail; + } vmspace->vm_tsize = text_size >> PAGE_SHIFT; vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; |