From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, qemu-stable@nongnu.org
Subject: Re: [PATCH v2] util: fix use-after-free in module_load_one
Date: Tue, 16 Mar 2021 16:59:34 +0100 [thread overview]
Message-ID: <6560fca2-cfe2-c96b-1b57-19970d8ae036@redhat.com> (raw)
In-Reply-To: <20210316134456.3243102-1-marcandre.lureau@redhat.com>
On 3/16/21 2:44 PM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> g_hash_table_add always retains ownership of the pointer passed in as
> the key. Its return status merely indicates whether the added entry was
> new, or replaced an existing entry. Thus key must never be freed after
> this method returns.
>
> Spotted by ASAN:
>
> ==2407186==ERROR: AddressSanitizer: heap-use-after-free on address 0x6020003ac4f0 at pc 0x7ffff766659c bp 0x7fffffffd1d0 sp 0x7fffffffc980
> READ of size 1 at 0x6020003ac4f0 thread T0
> #0 0x7ffff766659b (/lib64/libasan.so.6+0x8a59b)
> #1 0x7ffff6bfa843 in g_str_equal ../glib/ghash.c:2303
> #2 0x7ffff6bf8167 in g_hash_table_lookup_node ../glib/ghash.c:493
> #3 0x7ffff6bf9b78 in g_hash_table_insert_internal ../glib/ghash.c:1598
> #4 0x7ffff6bf9c32 in g_hash_table_add ../glib/ghash.c:1689
> #5 0x5555596caad4 in module_load_one ../util/module.c:233
> #6 0x5555596ca949 in module_load_one ../util/module.c:225
> #7 0x5555596ca949 in module_load_one ../util/module.c:225
> #8 0x5555596cbdf4 in module_load_qom_all ../util/module.c:349
>
> Typical C bug...
>
> Fixes: 90629122d2e ("module: use g_hash_table_add()")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> util/module.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
prev parent reply other threads:[~2021-03-16 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 13:44 [PATCH v2] util: fix use-after-free in module_load_one marcandre.lureau
2021-03-16 15:59 ` Philippe Mathieu-Daudé [this message]
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=6560fca2-cfe2-c96b-1b57-19970d8ae036@redhat.com \
--to=philmd@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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 NNTP newsgroup(s).