]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SEV: WARN if KVM attempts to setup scratch area with min_len==0
authorSean Christopherson <seanjc@google.com>
Fri, 1 May 2026 20:22:32 +0000 (13:22 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 May 2026 18:25:28 +0000 (20:25 +0200)
Now that all paths in KVM properly validate the length needed for the
scratch area, and are guaranteed to pass in a non-zero length, WARN if KVM
attempts to configured the scratch area with min_len==0 to guard against
future bugs.

Cc: stable@vger.kernel.org
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20260501202250.2115252-8-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c

index 6072fecfe994bb02a7aaf533bda440cb9983aafc..a3e85348ace9950348ad9d23e59a447455bd82eb 100644 (file)
@@ -3669,6 +3669,9 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 min_len)
        u64 scratch_gpa_beg, scratch_gpa_end;
        void *scratch_va;
 
+       if (WARN_ON_ONCE(!min_len))
+               goto e_scratch;
+
        scratch_gpa_beg = svm->sev_es.sw_scratch;
        if (!scratch_gpa_beg) {
                pr_err("vmgexit: scratch gpa not provided\n");