]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: ccp - Fix SNP panic notifier unregistration
authorAshish Kalra <ashish.kalra@amd.com>
Mon, 16 Jun 2025 21:50:27 +0000 (21:50 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:14 +0000 (16:34 +0200)
commit7e3d3e10f3a4b90f908e037917e4d0774127f250
tree25a77a94cd6c2121c1179798a468713206f2815b
parentbd1e33b90abd74843b720a47a187d4271012e38d
crypto: ccp - Fix SNP panic notifier unregistration

commit ab8b9fd39c45b7760093528cbef93e7353359d82 upstream.

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: 19860c3274fb ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/ccp/sev-dev.c