Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 14 Sep 2023 08:18:35 -0400
From: Rich Felker <>
To: Joakim Sindholt <>
Cc:, James R T <>
Subject: Re: [PATCH] Add a safe dequeue integrity check for mallocng

On Thu, Sep 14, 2023 at 11:23:08AM +0200, Joakim Sindholt wrote:
> On Thu, 14 Sep 2023 13:13:23 +0800, James R T <> wrote:
> > On Sat, Sep 9, 2023 at 8:48 AM Rich Felker <> wrote:
> > >
> > > This could and should be written with the assert macro, like all the
> > > other safety assertions in mallocng, not pulling in stdio and abort.
> > 
> > Understood. I was not able to find an assert with `predict_false` for
> > the condition. Should I add one assert function with `predict_false`
> > in `include/assert.h` or `src/exit/assert.c` or simply use the regular
> > assert?
> It's a little confusing but assert() in mallocng is not real assert():
> The issue is that if memory is under control of an attacker then doing
> anything at all, especially running the stdio machinery, is unsafe. To
> that end musl uses a_crash() here which expands to a minimal set of
> instructions to crash the process:

Yes. mallocng is written such that you could use the normal assert
with it, but presently it's just expanding to a_crash(). At some point
this might be revamped to crash with a message string in a particular
register or argument slot or something so that you get a bit more
meaningful information if looking at it in a debugger. And indeed, the
reason not to do any message printing, etc. is that you're running in
a known-compromised process state where any further complex execution
is unsafe (e.g. if the out-of-band malloc metadata was clobbered, the
function pointers in stderr might also have been clobbered, since the
latter are *easier to reach* than the OOB metadata).

> Furthermore, musl doesn't use any of thosed tagged branch tricks and I
> personally doubt it would make any difference.

Yes, the only reason libm.h has them is because nsz is using the code
in other environments that want them, and it made sense to avoid
gratuitous differences. We don't generally use those in musl. If the
compiler isn't generating good code and puts the failure path as a hot
path, we probably should explore whether the compiler is missing that
it's a does-not-return thing (which should always be treated as cold).
But indeed I doubt it makes a difference.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.