unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] malloc: Check for large bin list corruption when inserting unsorted chunk
@ 2019-02-12 16:13 Adam Maris
  2019-02-12 16:34 ` Adam Maris
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Maris @ 2019-02-12 16:13 UTC (permalink / raw)
  To: libc-alpha

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.

Tested with no regressions.

* malloc/malloc.c (_int_malloc): Add security checks for large bin
chunks when inserting unsorted chunk.

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 6e766d11bc..801ba1f499 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-05-15 16:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 16:13 [PATCH] malloc: Check for large bin list corruption when inserting unsorted chunk Adam Maris
2019-02-12 16:34 ` Adam Maris
2019-02-21 10:40   ` Adam Maris
2019-02-22  1:30   ` DJ Delorie
2019-03-06 12:09     ` Florian Weimer
2019-03-14 20:56       ` DJ Delorie
2019-05-15 15:50         ` Andreas Schwab
2019-05-15 16:12           ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).