public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ssmallkirby at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/27052] New: double free detection mechanism of tcache can invoke endless-loop in _int_free
Date: Fri, 11 Dec 2020 13:09:45 +0000	[thread overview]
Message-ID: <bug-27052-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=27052

            Bug ID: 27052
           Summary: double free detection mechanism of tcache can invoke
                    endless-loop in _int_free
           Product: glibc
           Version: 2.32
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: malloc
          Assignee: unassigned at sourceware dot org
          Reporter: ssmallkirby at gmail dot com
  Target Milestone: ---

Since glibc 2.29, tcache has a 'key' member, which detects double free of
tcache chunk.
If linked-list of tcache contains a loop, it invokes infinite loop in
_int_free. I think this loop should terminate and the program should abort if
tcache has more than 7 chunks.
Below code invokes such infinite loop in _int_free and the program never
terminates. It might be possible for this problem to be abused for DoS attack.

// tested on glibc 2.32
#include<stdio.h>
#include<stdlib.h>

unsigned long protect_ptr(unsigned long pos, unsigned long ptr){
  return (pos>>12) ^ (ptr);
}

int main(void)
{
  char *a,*b,*c;
  a = malloc(0x50);
  b = malloc(0x50);
  c = malloc(0x50);
  free(a);
  free(b);

  *(unsigned long*)(b) = (unsigned long*)protect_ptr(b, b);
  ((unsigned long*)c)[1] = ((unsigned long*)a)[1];
  free(c);

  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

                 reply	other threads:[~2020-12-11 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=bug-27052-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@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).