public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hkrawbytes at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug malloc/26306] New: Confusion in malloc.c about the fastbins size check. Date: Tue, 28 Jul 2020 07:19:38 +0000 [thread overview] Message-ID: <bug-26306-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=26306 Bug ID: 26306 Summary: Confusion in malloc.c about the fastbins size check. Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: malloc Assignee: unassigned at sourceware dot org Reporter: hkrawbytes at gmail dot com Target Milestone: --- Created attachment 12728 --> https://sourceware.org/bugzilla/attachment.cgi?id=12728&action=edit poc It looks like there's some confusion in malloc.c as to whether the fastbin index should be treated as an int or a long int during the fastbin size integrity check. The fastbin_idx macro casts the chunk size field down to an unsigned int, which is then confusingly stored as a long int for use in the integrity check. And it presents in the latest glibc versions and also in old one's. The result is that, the fastbin size integrity check only applies to the 4 least-significant bytes of the size field. Here's the POC. ``` #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char *i[7]; char *j; int s; char *k[7]; char *b; for(s = 0;s<7;s++) { i[s] = (char *) malloc(0x10); } j = (char *) malloc(0x10); for(s=0;s<7;s++) { free(i[s]); } free(j); memcpy((j - 0x8),"\x21\x00\x00\x00\x61\x61\x61\x61", 8); for(s=0;s<7;s++) { k[s] = (char *) malloc(0x10); } b = (char *) malloc(0x10); } ``` The fastbin size integrity check should check for the whole qword right?. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2020-07-28 7:19 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-28 7:19 hkrawbytes at gmail dot com [this message] 2020-07-28 9:53 ` [Bug malloc/26306] " fweimer at redhat dot com 2020-07-28 10:07 ` hkrawbytes at gmail dot com 2020-07-28 10:08 ` hkrawbytes at gmail dot com 2020-07-31 10:01 ` fweimer at redhat dot com
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-26306-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: linkBe 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).