Skip to content
/ linux Public

Commit 683be1d

Browse files
groeckgregkh
authored andcommitted
crypto: ccp - Fix leaking the same page twice
[ Upstream commit 5c52607 ] Commit 5511201 ("crypto: ccp - Fix a case where SNP_SHUTDOWN is missed") fixed a case where SNP is left in INIT state if page reclaim fails. It removes the transition to the INIT state for this command and adjusts the page state management. While doing this, it added a call to snp_leak_pages() after a call to snp_reclaim_pages() failed. Since snp_reclaim_pages() already calls snp_leak_pages() internally on the pages it fails to reclaim, calling it again leaks the exact same page twice. Fix by removing the extra call to snp_leak_pages(). The problem was found by an experimental code review agent based on gemini-3.1-pro while reviewing backports into v6.18.y. Assisted-by: Gemini:gemini-3.1-pro Fixes: 5511201 ("crypto: ccp - Fix a case where SNP_SHUTDOWN is missed") Cc: Tycho Andersen (AMD) <tycho@kernel.org> Cc: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Tycho Andersen (AMD) <tycho@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9d00fe7 commit 683be1d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/crypto/ccp/sev-dev.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,10 +2381,8 @@ static int sev_ioctl_do_snp_platform_status(struct sev_issue_cmd *argp)
23812381
* in Firmware state on failure. Use snp_reclaim_pages() to
23822382
* transition either case back to Hypervisor-owned state.
23832383
*/
2384-
if (snp_reclaim_pages(__pa(data), 1, true)) {
2385-
snp_leak_pages(__page_to_pfn(status_page), 1);
2384+
if (snp_reclaim_pages(__pa(data), 1, true))
23862385
return -EFAULT;
2387-
}
23882386
}
23892387

23902388
if (ret)

0 commit comments

Comments
 (0)