[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWgI-_2mxtTsx_li@google.com>
Date: Wed, 14 Jan 2026 13:22:03 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Hou Wenlong <houwenlong.hwl@...group.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: VMX: Don't register posted interrupt wakeup handler
if alloc_kvm_area() fails
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@...r.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@...group.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!
Powered by blists - more mailing lists