From: Xi Ruoyao <xry111@xry111.site>
To: Alejandro Colomar <alx@kernel.org>
Cc: Russ Allbery <eagle@eyrie.org>, libc-alpha@sourceware.org
Subject: Re: free(3) const void *
Date: Sat, 27 Jan 2024 02:49:42 +0800 [thread overview]
Message-ID: <0f059f2602e72f848a3f7acf27c937c7d63e2288.camel@xry111.site> (raw)
In-Reply-To: <ZbP8rDGokewImlsD@debian>
On Fri, 2024-01-26 at 19:40 +0100, Alejandro Colomar wrote:
> On Sat, Jan 27, 2024 at 02:36:09AM +0800, Xi Ruoyao wrote:
> > On Fri, 2024-01-26 at 19:23 +0100, Alejandro Colomar wrote:
> > > So, after Xi's reminder, I'll reformulate my suggestion to
> > >
> > > [[gnu::access(none)]]
> > > void free(const void *p);
> >
> > It may defeat glibc.malloc.perturb, which will fill the freed buffer
> > with some junk bytes to detect UAF more easily. Without the access
> > attribute the compiler will (definitely) read these junk bytes from the
> > freed buffer and hopefully make the program fail in a catastrophic way,
> > but with the access attribute the compiler may reuse the previously read
> > value stored in some registers, causing the UAF slip away.
> >
> > And glibc.malloc.perturb is an environment variable set at runtime, so
> > we cannot do it via some #if...
>
> Hmmm, interesting. Then please ignore the patch I sent a moment ago.
> :)
Back on the topic, IMO you may tell others to create wrappers like
[[gnu::access(none, 1)]] static inline void
aggressive_free (const void *p)
{
(free) ((void *)p);
}
#define free(x) aggressive_free (x)
with some texts to explain all the caveats (like `free ("string
literal");` will be incorrectly accepted, and the glibc.malloc.perturb
or similar facilities in other malloc implementations, etc) in the man
page... But for the standard and/or the libc header it's a different
story. Anyway if such a wrapper is adopted widely it will be easier to
raise it to WG14 and Austin.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2024-01-26 18:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 13:21 Alejandro Colomar
2024-01-26 14:24 ` Arsen Arsenović
2024-01-26 15:35 ` Alejandro Colomar
2024-01-26 17:22 ` Arsen Arsenović
2024-01-26 17:55 ` Xi Ruoyao
2024-01-26 18:11 ` Alejandro Colomar
2024-01-26 20:04 ` Arsen Arsenović
2024-01-26 20:07 ` Arsen Arsenović
2024-01-26 17:40 ` Andreas Schwab
2024-01-26 19:45 ` Florian Weimer
2024-01-26 15:13 ` Andreas Schwab
2024-01-26 15:33 ` Alejandro Colomar
2024-01-26 18:09 ` Russ Allbery
2024-01-26 18:23 ` Alejandro Colomar
2024-01-26 18:36 ` Xi Ruoyao
2024-01-26 18:40 ` Alejandro Colomar
2024-01-26 18:49 ` Xi Ruoyao [this message]
2024-01-26 18:57 ` Alejandro Colomar
2024-01-26 18:40 ` Russ Allbery
2024-01-26 18:45 ` Alejandro Colomar
2024-01-26 19:41 ` Florian Weimer
2024-01-26 18:39 ` [PATCH] Use [[gnu::access(none)]] on free(3) Alejandro Colomar
2024-01-26 18:41 ` Alejandro Colomar
2024-01-26 21:23 ` Paul Eggert
2024-01-26 23:19 ` Alejandro Colomar
2024-01-27 13:21 ` Cristian Rodríguez
2024-02-13 15:19 ` Gabriel Ravier
2024-02-13 15:28 ` Alejandro Colomar
2024-01-26 21:11 ` free(3) const void * DJ Delorie
2024-01-26 21:30 ` Andreas Schwab
2024-01-26 21:47 ` DJ Delorie
2024-01-26 22:07 ` Andreas Schwab
2024-01-26 23:25 ` Alejandro Colomar
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=0f059f2602e72f848a3f7acf27c937c7d63e2288.camel@xry111.site \
--to=xry111@xry111.site \
--cc=alx@kernel.org \
--cc=eagle@eyrie.org \
--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).