qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Arusekk <floss@arusekk.pl>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH v2] linux-user: fix resource leaks in gen-vdso
Date: Thu, 12 Jun 2025 10:12:29 +0200	[thread overview]
Message-ID: <10691455.nUPlyArG6x@swift> (raw)
In-Reply-To: <20250513150346.1328217-1-berrange@redhat.com>

Tested-by: Arusekk <floss@arusekk.pl>

Thanks for the patch. I am just a drive-by contributor, not someone
experienced in qemu development, so take my feedback with a grain of salt.

> There are a number of resource leaks in gen-vdso. In theory they are
> harmless because this is a short lived process, but when building QEMU
> with --extra-cflags="-fsanitize=address" problems ensure. The gen-vdso
> program is run as part of the build, and that aborts due to the
> sanitizer identifying memory leaks, leaving QEMU unbuildable.

I have not encountered it personally before.
However, I can confirm that qemu fails to build using

./configure --target-list=x86_64-linux-user --extra-cflags=-fsanitize=address && make

on current master, and that the patch fixes it.

I use gcc (Gentoo Hardened 15.1.0 p1) 15.1.0 libasan.so.8.
Curiously, the leak does not happen e.g. for arm-linux-user target.

> This complaint is about the 'buf' variable, however, the FILE objects
> are also leaked in some error scenarios, so this fix refactors the
> cleanup paths to fix all leaks. For completeness it also reports an
> error if fclose() fails on 'inf'.

How about other error cases?

> diff --git a/linux-user/gen-vdso.c b/linux-user/gen-vdso.c
> index 721f38d5a3..fce9d5cbc3 100644
> --- a/linux-user/gen-vdso.c
> +++ b/linux-user/gen-vdso.c
> @@ -129,7 +130,6 @@ int main(int argc, char **argv)
>          fprintf(stderr, "%s: incomplete read\n", inf_name);
>          return EXIT_FAILURE;

Like this one. Are other places like here possible candidates to also goto cleanup?

- Arusekk <https://arusekk.pl>




  parent reply	other threads:[~2025-06-12  8:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 15:03 [PATCH v2] linux-user: fix resource leaks in gen-vdso Daniel P. Berrangé
2025-06-11 10:21 ` Daniel P. Berrangé
2025-06-12  8:12 ` Arusekk [this message]
2025-06-23 19:11 ` Richard Henderson

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=10691455.nUPlyArG6x@swift \
    --to=floss@arusekk.pl \
    --cc=berrange@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@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).