unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] malloc: Check for large bin list corruption when inserting unsorted chunk
Date: Wed, 06 Mar 2019 13:09:46 +0100	[thread overview]
Message-ID: <87h8cgcigl.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <xnmumoa9tf.fsf@greed.delorie.com> (DJ Delorie's message of "Thu, 21 Feb 2019 20:30:52 -0500")

* DJ Delorie:

> Adam Maris <amaris@redhat.com> writes:
>>                          {
>>                            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)");
>
> At this point, the size of the chunk matches neither the previous nor
> next chunks; we're creating a new "unique size" sub-head.  So, both fd
> and fd_nextsize should point to the next (fwd) chunk.  We've hooked in
> our new chunk but haven't yet fixed up the existing chunks, so this test
> verifies that the links between the next chunk (fwd, which is a
> start-of-size chunk) and the previous start-of-size chunk are still
> cyclic.  Ok.
>
>>                            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)");
>
> At this point the newly inserted chunk may be a start-of-size chunk, or
> a second-in-size chunk; either way, we've not yet linked it into the
> fd-bk chain, so we can verify that the fwd->bk->fd is still cyclic.  Ok.
>
> So, looks correct to me.
> Reviewed-by: DJ Delorie <dj@redhat.com>

I agree with this analysis.

Adam's submission is no longer covered by the Red Hat copyright
assignment, though, but I believe we can still accept it because it was
submitted under the assignment, and it is a small change anyway.

Thanks,
Florian

  reply	other threads:[~2019-03-06 12:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-03-14 20:56       ` DJ Delorie
2019-05-15 15:50         ` Andreas Schwab
2019-05-15 16:12           ` DJ Delorie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8cgcigl.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).