about summary refs log tree commit diff
path: root/ChangeLog
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2015-06-08 13:36:13 +0100
committerAndreas Schwab <schwab@linux-m68k.org>2015-06-26 22:47:45 +0200
commitf8ef472c0ff4644445ec716036d31430b4fa4bab (patch)
tree84b0109c810049cacdb5d59dc9524df7b6e4ba22 /ChangeLog
parenta2057c984e4314c3740f04cf54e36c824e4c8f32 (diff)
downloadglibc-f8ef472c0ff4644445ec716036d31430b4fa4bab.tar.gz
glibc-f8ef472c0ff4644445ec716036d31430b4fa4bab.tar.xz
glibc-f8ef472c0ff4644445ec716036d31430b4fa4bab.zip
malloc: Do not corrupt the top of a threaded heap if top chunk is MINSIZE [BZ #18502]
mksquashfs was reported in openSUSE to be causing segmentation faults when
creating installation images. Testing showed that mksquashfs sometimes
failed and could be reproduced within 10 attempts. The core dump looked
like the heap top was corrupted and was pointing to an unmapped area. In
other cases, this has been due to an application corrupting glibc structures
but mksquashfs appears to be fine in this regard.

The problem is that heap_trim is "growing" the top into unmapped space.
If the top chunk == MINSIZE then top_area is -1 and this check does not
behave as expected due to a signed/unsigned comparison

  if (top_area <= pad)
    return 0;

The next calculation extra = ALIGN_DOWN(top_area - pad, pagesz) calculates
extra as a negative number which also is unnoticed due to a signed/unsigned
comparison. We then call shrink_heap(heap, negative_number) which crashes
later. This patch adds a simple check against MINSIZE to make sure extra
does not become negative. It adds a cast to hint to the reader that this
is a signed vs unsigned issue.

Without the patch, mksquash fails within 10 attempts. With it applied, it
completed 1000 times without error. The standard test suite "make check"
showed no changes in the summary of test results.
Diffstat (limited to 'ChangeLog')
-rw-r--r--ChangeLog6
1 files changed, 6 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b502c78f89..19cccdce62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-26  Mel Gorman  <mgorman@suse.de>
+
+	[BZ #18502]
+	* malloc/arena.c (heap_trim): Don't try to shrink a heap that is
+	already minimal.
+
 2015-06-26  Matthew Fortune  <matthew.fortune@imgtec.com>
 
 	* elf/elf.h (DT_MIPS_RLD_MAP_REL): New macro.