diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 48ffb3dc610a..16f735417072 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -82,9 +82,7 @@ static int set_brk(unsigned long start, unsigned long end) | |||
82 | end = ELF_PAGEALIGN(end); | 82 | end = ELF_PAGEALIGN(end); |
83 | if (end > start) { | 83 | if (end > start) { |
84 | unsigned long addr; | 84 | unsigned long addr; |
85 | down_write(¤t->mm->mmap_sem); | 85 | addr = vm_brk(start, end - start); |
86 | addr = do_brk(start, end - start); | ||
87 | up_write(¤t->mm->mmap_sem); | ||
88 | if (BAD_ADDR(addr)) | 86 | if (BAD_ADDR(addr)) |
89 | return addr; | 87 | return addr; |
90 | } | 88 | } |
@@ -514,9 +512,7 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex, | |||
514 | elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1); | 512 | elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1); |
515 | 513 | ||
516 | /* Map the last of the bss segment */ | 514 | /* Map the last of the bss segment */ |
517 | down_write(¤t->mm->mmap_sem); | 515 | error = vm_brk(elf_bss, last_bss - elf_bss); |
518 | error = do_brk(elf_bss, last_bss - elf_bss); | ||
519 | up_write(¤t->mm->mmap_sem); | ||
520 | if (BAD_ADDR(error)) | 516 | if (BAD_ADDR(error)) |
521 | goto out_close; | 517 | goto out_close; |
522 | } | 518 | } |
@@ -962,10 +958,8 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
962 | and some applications "depend" upon this behavior. | 958 | and some applications "depend" upon this behavior. |
963 | Since we do not have the power to recompile these, we | 959 | Since we do not have the power to recompile these, we |
964 | emulate the SVr4 behavior. Sigh. */ | 960 | emulate the SVr4 behavior. Sigh. */ |
965 | down_write(¤t->mm->mmap_sem); | 961 | error = vm_mmap(NULL, 0, PAGE_SIZE, PROT_READ | PROT_EXEC, |
966 | error = do_mmap(NULL, 0, PAGE_SIZE, PROT_READ | PROT_EXEC, | ||
967 | MAP_FIXED | MAP_PRIVATE, 0); | 962 | MAP_FIXED | MAP_PRIVATE, 0); |
968 | up_write(¤t->mm->mmap_sem); | ||
969 | } | 963 | } |
970 | 964 | ||
971 | #ifdef ELF_PLAT_INIT | 965 | #ifdef ELF_PLAT_INIT |
@@ -1050,8 +1044,7 @@ static int load_elf_library(struct file *file) | |||
1050 | eppnt++; | 1044 | eppnt++; |
1051 | 1045 | ||
1052 | /* Now use mmap to map the library into memory. */ | 1046 | /* Now use mmap to map the library into memory. */ |
1053 | down_write(¤t->mm->mmap_sem); | 1047 | error = vm_mmap(file, |
1054 | error = do_mmap(file, | ||
1055 | ELF_PAGESTART(eppnt->p_vaddr), | 1048 | ELF_PAGESTART(eppnt->p_vaddr), |
1056 | (eppnt->p_filesz + | 1049 | (eppnt->p_filesz + |
1057 | ELF_PAGEOFFSET(eppnt->p_vaddr)), | 1050 | ELF_PAGEOFFSET(eppnt->p_vaddr)), |
@@ -1059,7 +1052,6 @@ static int load_elf_library(struct file *file) | |||
1059 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, | 1052 | MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE, |
1060 | (eppnt->p_offset - | 1053 | (eppnt->p_offset - |
1061 | ELF_PAGEOFFSET(eppnt->p_vaddr))); | 1054 | ELF_PAGEOFFSET(eppnt->p_vaddr))); |
1062 | up_write(¤t->mm->mmap_sem); | ||
1063 | if (error != ELF_PAGESTART(eppnt->p_vaddr)) | 1055 | if (error != ELF_PAGESTART(eppnt->p_vaddr)) |
1064 | goto out_free_ph; | 1056 | goto out_free_ph; |
1065 | 1057 | ||
@@ -1072,11 +1064,8 @@ static int load_elf_library(struct file *file) | |||
1072 | len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + | 1064 | len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + |
1073 | ELF_MIN_ALIGN - 1); | 1065 | ELF_MIN_ALIGN - 1); |
1074 | bss = eppnt->p_memsz + eppnt->p_vaddr; | 1066 | bss = eppnt->p_memsz + eppnt->p_vaddr; |
1075 | if (bss > len) { | 1067 | if (bss > len) |
1076 | down_write(¤t->mm->mmap_sem); | 1068 | vm_brk(len, bss - len); |
1077 | do_brk(len, bss - len); | ||
1078 | up_write(¤t->mm->mmap_sem); | ||
1079 | } | ||
1080 | error = 0; | 1069 | error = 0; |
1081 | 1070 | ||
1082 | out_free_ph: | 1071 | out_free_ph: |