Sorry for interrupting this flamewar....

A simplified patch has been  included in 2.6.10-bk. It can be found at 

http://linux.bkbits.net:8080/linux-2.5/cset%401.2251?nav=index.html

or below.

I have only tested this patch on 2.6.10-mm2, and there it is *not*
sufficient. The machine does an instant reset, just as without the patch
or the older version from 2.4.

Regards

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/07 15:58:52-08:00 [EMAIL PROTECTED] 
#   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.
# 
# fs/binfmt_aout.c
#   2005/01/07 15:58:44-08:00 [EMAIL PROTECTED] +2 -0
#   Fix do_brk() locking in library loader
# 
# fs/binfmt_elf.c
#   2005/01/07 15:58:45-08:00 [EMAIL PROTECTED] +4 -1
#   Fix do_brk() locking in library loader
# 
diff -Nru a/fs/binfmt_aout.c b/fs/binfmt_aout.c
--- a/fs/binfmt_aout.c  2005-01-08 12:21:32 -08:00
+++ b/fs/binfmt_aout.c  2005-01-08 12:21:32 -08:00
@@ -512,7 +512,9 @@
        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 -Nru a/fs/binfmt_elf.c b/fs/binfmt_elf.c
--- a/fs/binfmt_elf.c   2005-01-08 12:21:32 -08:00
+++ b/fs/binfmt_elf.c   2005-01-08 12:21:32 -08:00
@@ -1024,8 +1024,11 @@
 
        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:

--
[email protected] mailing list

Reply via email to