diff options
| author | Dionna Glaze <[email protected]> | 2024-11-05 01:05:48 +0000 |
|---|---|---|
| committer | Paolo Bonzini <[email protected]> | 2024-11-08 05:57:13 -0500 |
| commit | e3a7792d96765ff435f3000e94619fcef2f6bfec (patch) | |
| tree | 4a4d27bfa42c0b243b9f25b4178f2193afda1350 | |
| parent | 10299cdde869abab7a42fb5ab905a47a4e2cd24e (diff) | |
kvm: svm: Fix gctx page leak on invalid inputs
Ensure that snp gctx page allocation is adequately deallocated on
failure during snp_launch_start.
Fixes: 136d8bc931c8 ("KVM: SEV: Add KVM_SEV_SNP_LAUNCH_START command")
CC: Sean Christopherson <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: Ashish Kalra <[email protected]>
CC: Tom Lendacky <[email protected]>
CC: John Allen <[email protected]>
CC: Herbert Xu <[email protected]>
CC: "David S. Miller" <[email protected]>
CC: Michael Roth <[email protected]>
CC: Luis Chamberlain <[email protected]>
CC: Russ Weight <[email protected]>
CC: Danilo Krummrich <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: "Rafael J. Wysocki" <[email protected]>
CC: Tianfei zhang <[email protected]>
CC: Alexey Kardashevskiy <[email protected]>
Signed-off-by: Dionna Glaze <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
| -rw-r--r-- | arch/x86/kvm/svm/sev.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 03c7db3b4cc3..fb854cf20ac3 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2215,10 +2215,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp) if (sev->snp_context) return -EINVAL; - sev->snp_context = snp_context_create(kvm, argp); - if (!sev->snp_context) - return -ENOTTY; - if (params.flags) return -EINVAL; @@ -2233,6 +2229,10 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp) if (params.policy & SNP_POLICY_MASK_SINGLE_SOCKET) return -EINVAL; + sev->snp_context = snp_context_create(kvm, argp); + if (!sev->snp_context) + return -ENOTTY; + start.gctx_paddr = __psp_pa(sev->snp_context); start.policy = params.policy; memcpy(start.gosvw, params.gosvw, sizeof(params.gosvw)); |