aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-06 23:58:52 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-06 23:58:52 -0800
commit19a92c413039e523547dfca209b0ee69a34bb176 (patch)
tree6865bd2e48a74ba4bca49ac9ed643808aaf183ed /fs
parent6ee22f53fae6cfc2f77f2462e725e41e6771dc5d (diff)
downloadhistory-19a92c413039e523547dfca209b0ee69a34bb176.tar.gz
Fix do_brk() locking in library loader
The regular executable loader path doesn't need the locking, because it's the only user of its VM. But the same is not true at library load time. So get the mmap semaphore.
Diffstat (limited to 'fs')
-rw-r--r--fs/binfmt_aout.c2
-rw-r--r--fs/binfmt_elf.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 24194a43f32a6f..acdd5384856651 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -512,7 +512,9 @@ static int load_aout_library(struct file *file)
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
if (bss > len) {
+ down_write(&current->mm->mmap_sem);
error = do_brk(start_addr + len, bss - len);
+ up_write(&current->mm->mmap_sem);
retval = error;
if (error != start_addr + len)
goto out;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 66846bc4385600..4f7e1203b037a5 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1024,8 +1024,11 @@ static int load_elf_library(struct file *file)
len = ELF_PAGESTART(elf_phdata->p_filesz + elf_phdata->p_vaddr + ELF_MIN_ALIGN - 1);
bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
- if (bss > len)
+ if (bss > len) {
+ down_write(&current->mm->mmap_sem);
do_brk(len, bss - len);
+ up_write(&current->mm->mmap_sem);
+ }
error = 0;
out_free_ph: