diff -u eglibc-2.15/debian/changelog eglibc-2.15/debian/changelog --- eglibc-2.15/debian/changelog +++ eglibc-2.15/debian/changelog @@ -1,3 +1,9 @@ +eglibc (2.15-0ubuntu10.10) precise; urgency=medium + + * Fix race in free() (LP: #1020210) + + -- Dariusz Gadomski Fri, 16 Jan 2015 12:46:39 -0200 + eglibc (2.15-0ubuntu10.9) precise-security; urgency=medium * SECURITY UPDATE: denial of service in IBM gconv modules diff -u eglibc-2.15/debian/patches/series eglibc-2.15/debian/patches/series --- eglibc-2.15/debian/patches/series +++ eglibc-2.15/debian/patches/series @@ -202,0 +203 @@ +ubuntu/fix-race-in-free.patch only in patch2: unchanged: --- eglibc-2.15.orig/debian/patches/ubuntu/fix-race-in-free.patch +++ eglibc-2.15/debian/patches/ubuntu/fix-race-in-free.patch @@ -0,0 +1,58 @@ +Description: Fix race in free() of fastbin chunk + Perform sanity check only if we have_lock. Due to lockless nature of fastbins + we need to be careful derefencing pointers to fastbin entries (chunksize(old) + in this case) in multithreaded environments. + + The fix is to add have_lock to the if-condition checks. The rest of the patch + only makes code more readable. + . + eglibc (2.15-0ubuntu10.10) precise; urgency=medium + . + * Fix race in free() (LP: #1020210) +Origin: upstream, https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commit;h=362b47fe09ca9a928d444c7e2f7992f7f61bfc3e +Author: Maxim Kuvyrkov +Last-Update: 2014-11-04 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1020210 + +Index: eglibc-2.15/malloc/malloc.c +=================================================================== +--- eglibc-2.15.orig/malloc/malloc.c 2014-11-04 10:24:20.195568736 -0200 ++++ eglibc-2.15/malloc/malloc.c 2014-11-04 10:24:58.863343544 -0200 +@@ -3989,25 +3989,29 @@ + unsigned int idx = fastbin_index(size); + fb = &fastbin (av, idx); + +- mchunkptr fd; +- mchunkptr old = *fb; ++ /* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */ ++ mchunkptr old = *fb, old2; + unsigned int old_idx = ~0u; + do + { +- /* Another simple check: make sure the top of the bin is not the +- record we are going to add (i.e., double free). */ ++ /* Check that the top of the bin is not the record we are going to add ++ (i.e., double free). */ + if (__builtin_expect (old == p, 0)) + { + errstr = "double free or corruption (fasttop)"; + goto errout; + } +- if (old != NULL) ++ /* Check that size of fastbin chunk at the top is the same as ++ size of the chunk that we are adding. We can dereference OLD ++ only if we have the lock, otherwise it might have already been ++ deallocated. See use of OLD_IDX below for the actual check. */ ++ if (have_lock && old != NULL) + old_idx = fastbin_index(chunksize(old)); +- p->fd = fd = old; ++ p->fd = old2 = old; + } +- while ((old = catomic_compare_and_exchange_val_rel (fb, p, fd)) != fd); ++ while ((old = catomic_compare_and_exchange_val_rel (fb, p, old2)) != old2); + +- if (fd != NULL && __builtin_expect (old_idx != idx, 0)) ++ if (have_lock && old != NULL && __builtin_expect (old_idx != idx, 0)) + { + errstr = "invalid fastbin entry (free)"; + goto errout;