From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: "Kees Cook" <keescook@chromium.org>,
"Valdis Klētnieks" <valdis.kletnieks@vt.edu>,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Justin Forbes" <jmforbes@linuxtx.org>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] tools: Fix use-after-free for realloc(..., 0)
Date: Tue, 15 Feb 2022 17:42:35 -0300 [thread overview]
Message-ID: <YgwQO1Z0UmV241vg@kernel.org> (raw)
In-Reply-To: <20220214200730.a3qz6ocy2ohwafrt@treble>
Em Mon, Feb 14, 2022 at 12:07:30PM -0800, Josh Poimboeuf escreveu:
> On Sun, Feb 13, 2022 at 10:24:43AM -0800, Kees Cook wrote:
> > GCC 12 was correctly reporting a potential use-after-free condition in
> > the xrealloc helper. Fix the warning by avoiding an implicit "free(ptr)"
> > when size == 0:
> >
> > In file included from help.c:12:
> > In function 'xrealloc',
> > inlined from 'add_cmdname' at help.c:24:2: subcmd-util.h:56:23: error: pointer may be used after 'realloc' [-Werror=use-after-free]
> > 56 | ret = realloc(ptr, size);
> > | ^~~~~~~~~~~~~~~~~~
> > subcmd-util.h:52:21: note: call to 'realloc' here
> > 52 | void *ret = realloc(ptr, size);
> > | ^~~~~~~~~~~~~~~~~~
> > subcmd-util.h:58:31: error: pointer may be used after 'realloc' [-Werror=use-after-free]
> > 58 | ret = realloc(ptr, 1);
> > | ^~~~~~~~~~~~~~~
> > subcmd-util.h:52:21: note: call to 'realloc' here
> > 52 | void *ret = realloc(ptr, size);
> > | ^~~~~~~~~~~~~~~~~~
> >
> > Reported-by: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
> > Fixes: 2f4ce5ec1d44 ("perf tools: Finalize subcmd independence")
> > Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> > v1: https://lore.kernel.org/lkml/20220212181855.3460176-1-keescook@chromium.org/
> > v2: simplify logic (josh)
>
> Thanks, running through testing now.
I assume that testing went ok, may I add a Tested-by: you?
- Arnaldo
next prev parent reply other threads:[~2022-02-15 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-13 18:24 [PATCH v2] tools: Fix use-after-free for realloc(..., 0) Kees Cook
2022-02-14 20:07 ` Josh Poimboeuf
2022-02-15 20:42 ` Arnaldo Carvalho de Melo [this message]
2022-02-15 22:14 ` Josh Poimboeuf
2022-02-15 20:58 ` Justin Forbes
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=YgwQO1Z0UmV241vg@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jmforbes@linuxtx.org \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=valdis.kletnieks@vt.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.