Skip to content

Commit ab8b9fd

Browse files
ashkalraherbertx
authored andcommitted
crypto: ccp - Fix SNP panic notifier unregistration
Panic notifiers are invoked with RCU read lock held and when the SNP panic notifier tries to unregister itself from the panic notifier callback itself it causes a deadlock as notifier unregistration does RCU synchronization. Code flow for SNP panic notifier: snp_shutdown_on_panic() -> __sev_firmware_shutdown() -> __sev_snp_shutdown_locked() -> atomic_notifier_chain_unregister(.., &snp_panic_notifier) Fix SNP panic notifier to unregister itself during SNP shutdown only if panic is not in progress. Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Cc: stable@vger.kernel.org Fixes: 19860c3 ("crypto: ccp - Register SNP panic notifier only if SNP is enabled") Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f5ad93f commit ab8b9fd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/crypto/ccp/sev-dev.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,14 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
17871787
sev->snp_initialized = false;
17881788
dev_dbg(sev->dev, "SEV-SNP firmware shutdown\n");
17891789

1790-
atomic_notifier_chain_unregister(&panic_notifier_list,
1791-
&snp_panic_notifier);
1790+
/*
1791+
* __sev_snp_shutdown_locked() deadlocks when it tries to unregister
1792+
* itself during panic as the panic notifier is called with RCU read
1793+
* lock held and notifier unregistration does RCU synchronization.
1794+
*/
1795+
if (!panic)
1796+
atomic_notifier_chain_unregister(&panic_notifier_list,
1797+
&snp_panic_notifier);
17921798

17931799
/* Reset TMR size back to default */
17941800
sev_es_tmr_size = SEV_TMR_SIZE;

0 commit comments

Comments
 (0)