diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 18:35:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 20:28:17 -0400 |
commit | e4eb1ff61b323d6141614e5458a1f53c7046ff8e (patch) | |
tree | 7a0251509c169b0df1a6bf4bc47c5bca709e06da /arch/x86/ia32 | |
parent | 3b422e9c2c020a1137349c614da7f9c9761a0922 (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 'arch/x86/ia32')
-rw-r--r-- | arch/x86/ia32/ia32_aout.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index d511d951a052..b6817ee9033f 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c | |||
@@ -119,9 +119,7 @@ static void set_brk(unsigned long start, unsigned long end) | |||
119 | end = PAGE_ALIGN(end); | 119 | end = PAGE_ALIGN(end); |
120 | if (end <= start) | 120 | if (end <= start) |
121 | return; | 121 | return; |
122 | down_write(¤t->mm->mmap_sem); | 122 | vm_brk(start, end - start); |
123 | do_brk(start, end - start); | ||
124 | up_write(¤t->mm->mmap_sem); | ||
125 | } | 123 | } |
126 | 124 | ||
127 | #ifdef CORE_DUMP | 125 | #ifdef CORE_DUMP |
@@ -332,9 +330,7 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
332 | pos = 32; | 330 | pos = 32; |
333 | map_size = ex.a_text+ex.a_data; | 331 | map_size = ex.a_text+ex.a_data; |
334 | 332 | ||
335 | down_write(¤t->mm->mmap_sem); | 333 | error = vm_brk(text_addr & PAGE_MASK, map_size); |
336 | error = do_brk(text_addr & PAGE_MASK, map_size); | ||
337 | up_write(¤t->mm->mmap_sem); | ||
338 | 334 | ||
339 | if (error != (text_addr & PAGE_MASK)) { | 335 | if (error != (text_addr & PAGE_MASK)) { |
340 | send_sig(SIGKILL, current, 0); | 336 | send_sig(SIGKILL, current, 0); |
@@ -373,9 +369,7 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
373 | if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) { | 369 | if (!bprm->file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) { |
374 | loff_t pos = fd_offset; | 370 | loff_t pos = fd_offset; |
375 | 371 | ||
376 | down_write(¤t->mm->mmap_sem); | 372 | vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); |
377 | do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); | ||
378 | up_write(¤t->mm->mmap_sem); | ||
379 | bprm->file->f_op->read(bprm->file, | 373 | bprm->file->f_op->read(bprm->file, |
380 | (char __user *)N_TXTADDR(ex), | 374 | (char __user *)N_TXTADDR(ex), |
381 | ex.a_text+ex.a_data, &pos); | 375 | ex.a_text+ex.a_data, &pos); |
@@ -476,9 +470,7 @@ static int load_aout_library(struct file *file) | |||
476 | error_time = jiffies; | 470 | error_time = jiffies; |
477 | } | 471 | } |
478 | #endif | 472 | #endif |
479 | down_write(¤t->mm->mmap_sem); | 473 | vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); |
480 | do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); | ||
481 | up_write(¤t->mm->mmap_sem); | ||
482 | 474 | ||
483 | file->f_op->read(file, (char __user *)start_addr, | 475 | file->f_op->read(file, (char __user *)start_addr, |
484 | ex.a_text + ex.a_data, &pos); | 476 | ex.a_text + ex.a_data, &pos); |
@@ -503,9 +495,7 @@ static int load_aout_library(struct file *file) | |||
503 | len = PAGE_ALIGN(ex.a_text + ex.a_data); | 495 | len = PAGE_ALIGN(ex.a_text + ex.a_data); |
504 | bss = ex.a_text + ex.a_data + ex.a_bss; | 496 | bss = ex.a_text + ex.a_data + ex.a_bss; |
505 | if (bss > len) { | 497 | if (bss > len) { |
506 | down_write(¤t->mm->mmap_sem); | 498 | error = vm_brk(start_addr + len, bss - len); |
507 | error = do_brk(start_addr + len, bss - len); | ||
508 | up_write(¤t->mm->mmap_sem); | ||
509 | retval = error; | 499 | retval = error; |
510 | if (error != start_addr + len) | 500 | if (error != start_addr + len) |
511 | goto out; | 501 | goto out; |