Blame SOURCES/glibc-rh593396.patch

b40826
2010-05-06  Ulrich Drepper  <drepper@redhat.com>
b40826
b40826
	* malloc/malloc.c (_int_free): Possible race in the most recently
b40826
	added check.  Only act on the data if no current modification
b40826
	happened.
b40826
b40826
Index: glibc-2.12-2-gc4ccff1/malloc/malloc.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/malloc/malloc.c
b40826
+++ glibc-2.12-2-gc4ccff1/malloc/malloc.c
b40826
@@ -4859,6 +4859,7 @@ _int_free(mstate av, mchunkptr p)
b40826
 #ifdef ATOMIC_FASTBINS
b40826
     mchunkptr fd;
b40826
     mchunkptr old = *fb;
b40826
+    unsigned int old_idx = ~0u;
b40826
     do
b40826
       {
b40826
 	/* Another simple check: make sure the top of the bin is not the
b40826
@@ -4868,15 +4869,17 @@ _int_free(mstate av, mchunkptr p)
b40826
 	    errstr = "double free or corruption (fasttop)";
b40826
 	    goto errout;
b40826
 	  }
b40826
-	if (old != NULL
b40826
-	    && __builtin_expect (fastbin_index(chunksize(old)) != idx, 0))
b40826
-	  {
b40826
-	    errstr = "invalid fastbin entry (free)";
b40826
-	    goto errout;
b40826
-	  }
b40826
+	if (old != NULL)
b40826
+	  old_idx = fastbin_index(chunksize(old));
b40826
 	p->fd = fd = old;
b40826
       }
b40826
     while ((old = catomic_compare_and_exchange_val_rel (fb, p, fd)) != fd);
b40826
+
b40826
+    if (fd != NULL && __builtin_expect (old_idx != idx, 0))
b40826
+      {
b40826
+	errstr = "invalid fastbin entry (free)";
b40826
+	goto errout;
b40826
+      }
b40826
 #else
b40826
     /* Another simple check: make sure the top of the bin is not the
b40826
        record we are going to add (i.e., double free).  */