Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp: Initialize DBC ioctl mutex before registering device
@ 2026-08-29 13:34 Runyu Xiao
  2026-08-29 15:07 ` Tom Lendacky
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Runyu Xiao @ 2026-08-29 13:34 UTC (permalink / raw)
  To: mario.limonciello
  Cc: runyu.xiao, jianhao.xu, thomas.lendacky, john.allen, herbert,
	davem, linux-crypto, linux-kernel, stable

dbc_dev_init() registers the DBC misc device before initializing
ioctl_mutex. Once misc_register() publishes the device, userspace can
open it and invoke dbc_ioctl() while the mutex is still uninitialized.

Initialize ioctl_mutex before calling misc_register() so the published
ioctl callback always sees an initialized mutex.

Fixes: c04cf9e14f10 ("crypto: ccp - Add support for fetching a nonce for dynamic boost control")
Cc: stable@vger.kernel.org
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Assisted-by: Codex:GPT-5
---
 drivers/crypto/ccp/dbc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ccp/dbc.c b/drivers/crypto/ccp/dbc.c
index 410084a90..00c864413 100644
--- a/drivers/crypto/ccp/dbc.c
+++ b/drivers/crypto/ccp/dbc.c
@@ -240,12 +240,12 @@ int dbc_dev_init(struct psp_device *psp)
 	dbc_dev->char_dev.name = "dbc";
 	dbc_dev->char_dev.fops = &dbc_fops;
 	dbc_dev->char_dev.mode = 0600;
+	mutex_init(&dbc_dev->ioctl_mutex);
+
 	ret = misc_register(&dbc_dev->char_dev);
 	if (ret)
 		goto cleanup_mbox;
 
-	mutex_init(&dbc_dev->ioctl_mutex);
-
 	return 0;
 
 cleanup_mbox:

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-31 16:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-29 13:34 [PATCH] crypto: ccp: Initialize DBC ioctl mutex before registering device Runyu Xiao
2026-08-29 15:07 ` Tom Lendacky
2026-08-30  1:51 ` [PATCH v2] " Runyu Xiao
2026-08-30 15:19   ` Tom Lendacky
2026-08-31 16:08   ` Mario Limonciello
2026-08-31 16:07 ` [PATCH] " Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox