This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/214] sbrk() doesn't detect brk() failures. Malloc doesn't handle sbrk() failures


------- Additional Comments From rsa at us dot ibm dot com  2006-03-08 19:21 -------
Found the 'issue'.

In the Linux kernel in the sys_brk syscall handler:

mm/mmap.c:sys_brk

...

        if (brk < mm->end_code)
                goto out;
        newbrk = PAGE_ALIGN(brk);
        oldbrk = PAGE_ALIGN(mm->brk);
        if (oldbrk == newbrk)
                goto set_brk;

...

set_brk:
        mm->brk = brk;
out:
        retval = mm->brk;
        up_write(&mm->mmap_sem);
        return retval;

The Linux kernel operates in pages.  It checks the page boundary of the current
brk and the new brk and if they're the same it simply increment's the brk the
requested amount and returns.  It never checks the soft-limit if the brk request
falls within the same page of the current brk.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=214

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]