From: Stefan Weil via qemu development <qemu-devel@nongnu.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] tdx: fix use-after-free in tdx_fetch_cpuid
Date: Mon, 23 Mar 2026 10:49:11 +0100 [thread overview]
Message-ID: <5262a373-4492-4119-8231-04981e6a8782@weilnetz.de> (raw)
In-Reply-To: <20260323085527.2083921-1-pbonzini@redhat.com>
Am 23.03.26 um 09:55 schrieb Paolo Bonzini:
> This is mostly harmless right now because the "if" is never
> hit, but the code as written makes no sense.
>
> Reported-by: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> target/i386/kvm/tdx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
> index 4cae99c281a..4714c9d514e 100644
> --- a/target/i386/kvm/tdx.c
> +++ b/target/i386/kvm/tdx.c
> @@ -848,7 +848,7 @@ static struct kvm_cpuid2 *tdx_fetch_cpuid(CPUState *cpu, int *ret)
> r = tdx_vcpu_ioctl(cpu, KVM_TDX_GET_CPUID, 0, fetch_cpuid, &local_err);
> if (r == -E2BIG) {
> g_free(fetch_cpuid);
> - size = fetch_cpuid->nent;
> + size *= 2;
> }
> } while (r == -E2BIG);
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Paolo, thank you for the fast fix. The GitHub code scanning currently
reports 23 issues with severity critical (one fixed with the commit
above) or high. It might be a good idea to enable CodeQL for the
official mirror https://github.com/qemu/qemu.
Regards
Stefan
prev parent reply other threads:[~2026-03-23 9:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 8:55 [PATCH] tdx: fix use-after-free in tdx_fetch_cpuid Paolo Bonzini
2026-03-23 9:49 ` Stefan Weil via qemu development [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=5262a373-4492-4119-8231-04981e6a8782@weilnetz.de \
--to=qemu-devel@nongnu.org \
--cc=pbonzini@redhat.com \
--cc=sw@weilnetz.de \
/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