mbox series

[0/3] KVM: Fix for a mostly benign gpc WARN

Message ID 20240320001542.3203871-1-seanjc@google.com (mailing list archive)
Headers show
Series KVM: Fix for a mostly benign gpc WARN | expand

Message

Sean Christopherson March 20, 2024, 12:15 a.m. UTC
Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
magic INVALID_GPA, which would also fail the sanity check.

Sean Christopherson (3):
  KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
  KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
    activation
  KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
    INVALID_GPA

Sean Christopherson (3):
  KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
  KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
    activation
  KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
    INVALID_GPA

 virt/kvm/pfncache.c | 48 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 34 insertions(+), 14 deletions(-)


base-commit: 964d0c614c7f71917305a5afdca9178fe8231434

Comments

David Woodhouse March 22, 2024, 11:39 a.m. UTC | #1
On Tue, 2024-03-19 at 17:15 -0700, Sean Christopherson wrote:
> Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
> marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
> other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
> magic INVALID_GPA, which would also fail the sanity check.
> 
> Sean Christopherson (3):
>   KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
>   KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
>     activation
>   KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
>     INVALID_GPA

It looks like these conflict with
https://lore.kernel.org/kvm/20240227115648.3104-9-dwmw2@infradead.org/

Want to arrange them to come after it?
Sean Christopherson April 8, 2024, 11:21 p.m. UTC | #2
On Fri, Mar 22, 2024, David Woodhouse wrote:
> On Tue, 2024-03-19 at 17:15 -0700, Sean Christopherson wrote:
> > Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
> > marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
> > other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
> > magic INVALID_GPA, which would also fail the sanity check.
> > 
> > Sean Christopherson (3):
> >   KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
> >   KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
> >     activation
> >   KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
> >     INVALID_GPA
> 
> It looks like these conflict with
> https://lore.kernel.org/kvm/20240227115648.3104-9-dwmw2@infradead.org/
> 
> Want to arrange them to come after it?

Very belated, yes.  Though by the time you read this, they should be in
kvm-x86/next.
Sean Christopherson April 9, 2024, 2:01 a.m. UTC | #3
On Tue, 19 Mar 2024 17:15:39 -0700, Sean Christopherson wrote:
> Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
> marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
> other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
> magic INVALID_GPA, which would also fail the sanity check.
> 
> Sean Christopherson (3):
>   KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
>   KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
>     activation
>   KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
>     INVALID_GPA
> 
> [...]

Applied to kvm-x86 fixes, thanks!

[1/3] KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
      https://github.com/kvm-x86/linux/commit/18f06e976925
[2/3] KVM: Check validity of offset+length of gfn_to_pfn_cache prior to activation
      https://github.com/kvm-x86/linux/commit/5c9ca4ed8908
[3/3] KVM: Explicitly disallow activatating a gfn_to_pfn_cache with INVALID_GPA
      https://github.com/kvm-x86/linux/commit/fc62a4e8dee2

--
https://github.com/kvm-x86/linux/tree/next
David Woodhouse April 9, 2024, 2:33 a.m. UTC | #4
On Mon, 2024-04-08 at 16:21 -0700, Sean Christopherson wrote:
> On Fri, Mar 22, 2024, David Woodhouse wrote:
> > On Tue, 2024-03-19 at 17:15 -0700, Sean Christopherson wrote:
> > > Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
> > > marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
> > > other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
> > > magic INVALID_GPA, which would also fail the sanity check.
> > > 
> > > Sean Christopherson (3):
> > >   KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
> > >   KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
> > >     activation
> > >   KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
> > >     INVALID_GPA
> > 
> > It looks like these conflict with
> > https://lore.kernel.org/kvm/20240227115648.3104-9-dwmw2@infradead.org/
> > 
> > Want to arrange them to come after it?
> 
> Very belated, yes.  Though by the time you read this, they should be in
> kvm-x86/next.

Did that 'yes' mean 'no'? Because your three patches are in, but you
didn't arrange them to come after my 'clean up rwlock abuse' patch, as
you seemed to be saying 'yes' to...
Sean Christopherson April 9, 2024, 2:28 p.m. UTC | #5
On Tue, Apr 09, 2024, David Woodhouse wrote:
> On Mon, 2024-04-08 at 16:21 -0700, Sean Christopherson wrote:
> > On Fri, Mar 22, 2024, David Woodhouse wrote:
> > > On Tue, 2024-03-19 at 17:15 -0700, Sean Christopherson wrote:
> > > > Fix a bug found by syzkaller, thanks to a new WARN sanity check, where KVM
> > > > marks a gfn_to_pfn_cache as active without actually setting gpc->gpa or any
> > > > other metadata.  On top, harden against _directly_ setting gpc->gpa to KVM's
> > > > magic INVALID_GPA, which would also fail the sanity check.
> > > > 
> > > > Sean Christopherson (3):
> > > >   KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check
> > > >   KVM: Check validity of offset+length of gfn_to_pfn_cache prior to
> > > >     activation
> > > >   KVM: Explicitly disallow activatating a gfn_to_pfn_cache with
> > > >     INVALID_GPA
> > > 
> > > It looks like these conflict with
> > > https://lore.kernel.org/kvm/20240227115648.3104-9-dwmw2@infradead.org/
> > > 
> > > Want to arrange them to come after it?
> > 
> > Very belated, yes.  Though by the time you read this, they should be in
> > kvm-x86/next.
> 
> Did that 'yes' mean 'no'? Because your three patches are in, but you
> didn't arrange them to come after my 'clean up rwlock abuse' patch, as
> you seemed to be saying 'yes' to...

Doh, I misread your question, multiple times.  I thought you were asking if I
wanted you to arrange your patches after this series.

Your series goes on top because I want to land this series in 6.9 to fix the
syzkaller splat (which was effectively introduced in 6.9), whereas your patch is
6.10 material.