[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250602191017.60936-1-Ashish.Kalra@amd.com>
Date: Mon, 2 Jun 2025 19:10:17 +0000
From: Ashish Kalra <Ashish.Kalra@....com>
To: <thomas.lendacky@....com>, <john.allen@....com>,
<herbert@...dor.apana.org.au>, <davem@...emloft.net>
CC: <aik@....com>, <dionnaglaze@...gle.com>, <michael.roth@....com>,
<linux-crypto@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] crypto: ccp: Fix SNP panic notifier unregistration
From: Ashish Kalra <ashish.kalra@....com>
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.
Fix SNP panic notifier to unregister itself during module unload
if SNP is initialized.
Fixes: 19860c3274fb ("crypto: ccp - Register SNP panic notifier only if SNP is enabled")
Signed-off-by: Ashish Kalra <ashish.kalra@....com>
---
drivers/crypto/ccp/sev-dev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 8fb94c5f006a..942d93da1136 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1787,9 +1787,6 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
sev->snp_initialized = false;
dev_dbg(sev->dev, "SEV-SNP firmware shutdown\n");
- atomic_notifier_chain_unregister(&panic_notifier_list,
- &snp_panic_notifier);
-
/* Reset TMR size back to default */
sev_es_tmr_size = SEV_TMR_SIZE;
@@ -2562,4 +2559,8 @@ void sev_pci_exit(void)
return;
sev_firmware_shutdown(sev);
+
+ if (sev->snp_initialized)
+ atomic_notifier_chain_unregister(&panic_notifier_list,
+ &snp_panic_notifier);
}
--
2.34.1
Powered by blists - more mailing lists