aboutsummaryrefslogtreecommitdiffstats
path: root/fs/binfmt_aout.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-04-20 18:35:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-04-20 20:28:17 -0400
commite4eb1ff61b323d6141614e5458a1f53c7046ff8e (patch)
tree7a0251509c169b0df1a6bf4bc47c5bca709e06da /fs/binfmt_aout.c
parent3b422e9c2c020a1137349c614da7f9c9761a0922 (diff)
VM: add "vm_brk()" helper function
It does the same thing as "do_brk()", except it handles the VM locking too. It turns out that all external callers want that anyway, so we can make do_brk() static to just mm/mmap.c while at it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/binfmt_aout.c')
-rw-r--r--fs/binfmt_aout.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 2eb12f13593d..88527492b917 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -50,9 +50,7 @@ static int set_brk(unsigned long start, unsigned long end)
50 end = PAGE_ALIGN(end); 50 end = PAGE_ALIGN(end);
51 if (end > start) { 51 if (end > start) {
52 unsigned long addr; 52 unsigned long addr;
53 down_write(&current->mm->mmap_sem); 53 addr = vm_brk(start, end - start);
54 addr = do_brk(start, end - start);
55 up_write(&current->mm->mmap_sem);
56 if (BAD_ADDR(addr)) 54 if (BAD_ADDR(addr))
57 return addr; 55 return addr;
58 } 56 }
@@ -280,9 +278,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
280 pos = 32; 278 pos = 32;
281 map_size = ex.a_text+ex.a_data; 279 map_size = ex.a_text+ex.a_data;
282#endif 280#endif
283 down_write(&current->mm->mmap_sem); 281 error = vm_brk(text_addr & PAGE_MASK, map_size);
284 error = do_brk(text_addr & PAGE_MASK, map_size);
285 up_write(&current->mm->mmap_sem);
286 if (error != (text_addr & PAGE_MASK)) { 282 if (error != (text_addr & PAGE_MASK)) {
287 send_sig(SIGKILL, current, 0); 283 send_sig(SIGKILL, current, 0);
288 return error; 284 return error;
@@ -313,9 +309,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
313 309
314 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { 310 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
315 loff_t pos = fd_offset; 311 loff_t pos = fd_offset;
316 down_write(&current->mm->mmap_sem); 312 vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
317 do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
318 up_write(&current->mm->mmap_sem);
319 bprm->file->f_op->read(bprm->file, 313 bprm->file->f_op->read(bprm->file,
320 (char __user *)N_TXTADDR(ex), 314 (char __user *)N_TXTADDR(ex),
321 ex.a_text+ex.a_data, &pos); 315 ex.a_text+ex.a_data, &pos);
@@ -412,9 +406,7 @@ static int load_aout_library(struct file *file)
412 "N_TXTOFF is not page aligned. Please convert library: %s\n", 406 "N_TXTOFF is not page aligned. Please convert library: %s\n",
413 file->f_path.dentry->d_name.name); 407 file->f_path.dentry->d_name.name);
414 } 408 }
415 down_write(&current->mm->mmap_sem); 409 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
416 do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
417 up_write(&current->mm->mmap_sem);
418 410
419 file->f_op->read(file, (char __user *)start_addr, 411 file->f_op->read(file, (char __user *)start_addr,
420 ex.a_text + ex.a_data, &pos); 412 ex.a_text + ex.a_data, &pos);
@@ -438,9 +430,7 @@ static int load_aout_library(struct file *file)
438 len = PAGE_ALIGN(ex.a_text + ex.a_data); 430 len = PAGE_ALIGN(ex.a_text + ex.a_data);
439 bss = ex.a_text + ex.a_data + ex.a_bss; 431 bss = ex.a_text + ex.a_data + ex.a_bss;
440 if (bss > len) { 432 if (bss > len) {
441 down_write(&current->mm->mmap_sem); 433 error = vm_brk(start_addr + len, bss - len);
442 error = do_brk(start_addr + len, bss - len);
443 up_write(&current->mm->mmap_sem);
444 retval = error; 434 retval = error;
445 if (error != start_addr + len) 435 if (error != start_addr + len)
446 goto out; 436 goto out;