Re: [RESEND PATCH v3] crypto: ccp: Fix SNP panic notifier unregistration

From: Herbert Xu
Date: Mon Jun 23 2025 - 05:25:09 EST


On Mon, Jun 16, 2025 at 09:50:27PM +0000, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@xxxxxxx>
>
> 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@xxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 19860c3274fb ("crypto: ccp - Register SNP panic notifier only if SNP is enabled")
> Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx>
> ---
> drivers/crypto/ccp/sev-dev.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt