From: Sean Christopherson <seanjc@google.com>
To: Hou Wenlong <houwenlong.hwl@antgroup.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: VMX: Don't register posted interrupt wakeup handler if alloc_kvm_area() fails
Date: Wed, 14 Jan 2026 13:22:03 -0800 [thread overview]
Message-ID: <aWgI-_2mxtTsx_li@google.com> (raw)
In-Reply-To: <20260114031139.GA107826@k08j02272.eu95sqa>
On Wed, Jan 14, 2026, Hou Wenlong wrote:
> On Tue, Jan 13, 2026 at 08:17:23AM -0800, Sean Christopherson wrote:
> > On Tue, Jan 13, 2026, Hou Wenlong wrote:
> > > Unregistering the posted interrupt wakeup handler only happens during
> > > hardware unsetup. Therefore, if alloc_kvm_area() fails and continue to
> > > register the posted interrupt wakeup handler, this will leave the global
> > > posted interrupt wakeup handler pointer in an incorrect state. Although
> > > it should not be an issue, it's still better to change it.
> >
> > Ouch, yeah, that's ugly. It's not entirely benign, as a failed allocation followed
> > by a spurious notification vector IRQ would trigger UAF. So it's probably worth
> > adding:
> >
> > Fixes: ec5a4919fa7b ("KVM: VMX: Unregister posted interrupt wakeup handler on hardware unsetup")
> > Cc: stable@vger.kernel.org
> >
> Actually, I'm not sure which commit is better as the fix tag:
> 'bf9f6ac8d749' or 'ec5a4919fa7b'. Before commit 'ec5a4919fa7b', the
> handler was registered before alloc_kvm_areas() and was not unregistered
> if alloc_kvm_areas() failed. However, it seems my commit message
> description is more suitable for fixing 'ec5a4919fa7b'.
Yeah, and the Fixes: chain of <this patch> => ec5a4919fa7b => bf9f6ac8d749 provides
the context needed to get back to the original bug.
> > even though I agree it's extremely unlikely to be an issue in practice.
> >
> > > Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> > > ---
> > > arch/x86/kvm/vmx/vmx.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > > index 9b92f672ccfe..676f32aa72bb 100644
> > > --- a/arch/x86/kvm/vmx/vmx.c
> > > +++ b/arch/x86/kvm/vmx/vmx.c
> > > @@ -8829,8 +8829,11 @@ __init int vmx_hardware_setup(void)
> > > }
> > >
> > > r = alloc_kvm_area();
> > > - if (r && nested)
> > > - nested_vmx_hardware_unsetup();
> > > + if (r) {
> > > + if (nested)
> > > + nested_vmx_hardware_unsetup();
> > > + return r;
> > > + }
> >
> > I'm leaning towards using a goto with an explicit "return 0" in the happy case,
> > to make it less likely that a similar bug is introduced in the future. Any
> > preference on your end?
> >
> I don't have a strong preference either way. However, I agree that using
> a goto statement could help prevent potential bugs in the future. Do I
> Thanks!
Nah, I'll change it to a goto when applying.
Thanks!
next prev parent reply other threads:[~2026-01-14 21:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 11:56 [PATCH] KVM: VMX: Don't register posted interrupt wakeup handler if alloc_kvm_area() fails Hou Wenlong
2026-01-13 16:17 ` Sean Christopherson
2026-01-14 3:11 ` Hou Wenlong
2026-01-14 21:22 ` Sean Christopherson [this message]
2026-01-15 18:03 ` Sean Christopherson
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=aWgI-_2mxtTsx_li@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=houwenlong.hwl@antgroup.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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