FreeBSD Bugzilla – Attachment 8762 Details for
Bug 18209
rlimits are never checked in exec() if executable format is ELF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.12 KB, created by
jason
on 2000-04-25 18:20:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
jason
Created:
2000-04-25 18:20:01 UTC
Size:
2.12 KB
patch
obsolete
>Index: kern/imgact_elf.c >=================================================================== >RCS file: /home/cvsroot/jsn/sys/kern/imgact_elf.c,v >retrieving revision 1.1.1.1 >retrieving revision 1.4 >diff -u -r1.1.1.1 -r1.4 >--- kern/imgact_elf.c 2000/04/17 10:30:39 1.1.1.1 >+++ kern/imgact_elf.c 2000/04/25 16:52:11 1.4 >@@ -451,7 +451,39 @@ > return ENOEXEC; > } > phdr = (const Elf_Phdr*)(imgp->image_header + hdr->e_phoff); >+ >+ /* we better check rlimits *before* new vmspace is exec()-ed */ >+ for (i = 0; i < hdr->e_phnum; i++) { >+ if (phdr[i].p_type == PT_LOAD) { /* Loadable segment */ >+ /* >+ * Is this .text or .data ?? >+ * >+ * We only handle one each of those yet XXX >+ */ >+ if (hdr->e_entry >= phdr[i].p_vaddr && >+ hdr->e_entry <(phdr[i].p_vaddr+phdr[i].p_memsz)) { >+ text_addr = trunc_page(phdr[i].p_vaddr); >+ text_size = round_page(phdr[i].p_memsz + >+ phdr[i].p_vaddr - >+ text_addr); >+ entry = (u_long)hdr->e_entry; >+ } else { >+ data_addr = trunc_page(phdr[i].p_vaddr); >+ data_size = round_page(phdr[i].p_memsz + >+ phdr[i].p_vaddr - >+ data_addr); >+ } >+ } >+ } > >+ >+ if (text_size > MAXTSIZ || >+ text_size + data_size > >+ imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur) { >+ error = ENOMEM ; >+ goto fail ; >+ } >+ > /* > * From this point on, we may have resources that need to be freed. > */ >@@ -481,25 +513,6 @@ > phdr[i].p_memsz, > phdr[i].p_filesz, prot)) != 0) > goto fail; >- >- /* >- * Is this .text or .data ?? >- * >- * We only handle one each of those yet XXX >- */ >- if (hdr->e_entry >= phdr[i].p_vaddr && >- hdr->e_entry <(phdr[i].p_vaddr+phdr[i].p_memsz)) { >- text_addr = trunc_page(phdr[i].p_vaddr); >- text_size = round_page(phdr[i].p_memsz + >- phdr[i].p_vaddr - >- text_addr); >- entry = (u_long)hdr->e_entry; >- } else { >- data_addr = trunc_page(phdr[i].p_vaddr); >- data_size = round_page(phdr[i].p_memsz + >- phdr[i].p_vaddr - >- data_addr); >- } > break; > case PT_INTERP: /* Path to interpreter */ > if (phdr[i].p_filesz > MAXPATHLEN ||
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 18209
: 8762