Re: [PATCH for 5.4] Fix unsynchronized access to sev members through svm_register_enc_region
From: Greg KH
Date: Thu Feb 11 2021 - 09:29:07 EST
On Mon, Feb 08, 2021 at 08:48:55AM -0800, Peter Gonda wrote:
> commit 19a23da53932bc8011220bd8c410cb76012de004 upstream.
>
> Grab kvm->lock before pinning memory when registering an encrypted
> region; sev_pin_memory() relies on kvm->lock being held to ensure
> correctness when checking and updating the number of pinned pages.
>
> Add a lockdep assertion to help prevent future regressions.
>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Cc: Brijesh Singh <brijesh.singh@xxxxxxx>
> Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
> Cc: x86@xxxxxxxxxx
> Cc: kvm@xxxxxxxxxxxxxxx
> Cc: stable@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Fixes: 1e80fdc09d12 ("KVM: SVM: Pin guest memory when SEV is active")
> Signed-off-by: Peter Gonda <pgonda@xxxxxxxxxx>
>
> V2
> - Fix up patch description
> - Correct file paths svm.c -> sev.c
> - Add unlock of kvm->lock on sev_pin_memory error
>
> V1
> - https://lore.kernel.org/kvm/20210126185431.1824530-1-pgonda@xxxxxxxxxx/
>
> Message-Id: <20210127161524.2832400-1-pgonda@xxxxxxxxxx>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
> arch/x86/kvm/svm.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)a
Both backports now queued up, thanks.
greg k-h