Skip to content

Commit e3a7792

Browse files
deeglazebonzini
authored andcommitted
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: 136d8bc ("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]>
1 parent 10299cd commit e3a7792

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,10 +2215,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
22152215
if (sev->snp_context)
22162216
return -EINVAL;
22172217

2218-
sev->snp_context = snp_context_create(kvm, argp);
2219-
if (!sev->snp_context)
2220-
return -ENOTTY;
2221-
22222218
if (params.flags)
22232219
return -EINVAL;
22242220

@@ -2233,6 +2229,10 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
22332229
if (params.policy & SNP_POLICY_MASK_SINGLE_SOCKET)
22342230
return -EINVAL;
22352231

2232+
sev->snp_context = snp_context_create(kvm, argp);
2233+
if (!sev->snp_context)
2234+
return -ENOTTY;
2235+
22362236
start.gctx_paddr = __psp_pa(sev->snp_context);
22372237
start.policy = params.policy;
22382238
memcpy(start.gosvw, params.gosvw, sizeof(params.gosvw));

0 commit comments

Comments
 (0)