Commit 19a92c41 authored by Linus Torvalds's avatar Linus Torvalds

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.
parent 6ee22f53
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment