aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Maris <amaris@redhat.com>2019-03-14 16:51:16 -0400
committerAndreas K. Hüttel <dilfridge@gentoo.org>2019-07-04 00:44:30 +0200
commitfba150eb133d2e91bd8f6ff64fb8e9af173d4306 (patch)
tree54445eb1885c1346f7c806a36c5b5dbe44a52d92
parentelf: Fix pldd (BZ#18035) (diff)
downloadglibc-fba150eb133d2e91bd8f6ff64fb8e9af173d4306.tar.gz
glibc-fba150eb133d2e91bd8f6ff64fb8e9af173d4306.tar.bz2
glibc-fba150eb133d2e91bd8f6ff64fb8e9af173d4306.zip
malloc: Check for large bin list corruption when inserting unsorted chunk
Fixes bug 24216. This patch adds security checks for bk and bk_nextsize pointers of chunks in large bin when inserting chunk from unsorted bin. It was possible to write the pointer to victim (newly inserted chunk) to arbitrary memory locations if bk or bk_nextsize pointers of the next large bin chunk got corrupted. (cherry picked from commit 5b06f538c5aee0389ed034f60d90a8884d6d54de) (cherry picked from commit 52b7cd6e9a701bb203023d56e84551943dc6a4c0) Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
-rw-r--r--malloc/malloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index feaf7ee0bf..ce771375b6 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3876,10 +3876,14 @@ _int_malloc (mstate av, size_t bytes)
{
victim->fd_nextsize = fwd;
victim->bk_nextsize = fwd->bk_nextsize;
+ if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd))
+ malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)");
fwd->bk_nextsize = victim;
victim->bk_nextsize->fd_nextsize = victim;
}
bck = fwd->bk;
+ if (bck->fd != fwd)
+ malloc_printerr ("malloc(): largebin double linked list corrupted (bk)");
}
}
else