* [PATCH] crypto: ccp: Initialize DBC ioctl mutex before registering device
@ 2026-08-29 13:34 Runyu Xiao
2026-08-29 15:07 ` Tom Lendacky
2026-08-30 1:51 ` [PATCH v2] " Runyu Xiao
0 siblings, 2 replies; 4+ 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 [flat|nested] 4+ messages in thread
* Re: [PATCH] crypto: ccp: Initialize DBC ioctl mutex before registering device
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
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2026-08-29 15:07 UTC (permalink / raw)
To: Runyu Xiao, mario.limonciello
Cc: jianhao.xu, john.allen, herbert, davem, linux-crypto,
linux-kernel, stable
On 8/29/26 08:34, Runyu Xiao wrote:
> 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);
This mixes it in with the misc_register() settings and the call, move it
to just before all the settings.
Thanks,
Tom
> +
> 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 [flat|nested] 4+ messages in thread
* [PATCH v2] crypto: ccp: Initialize DBC ioctl mutex before registering device
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 ` Runyu Xiao
2026-08-30 15:19 ` Tom Lendacky
1 sibling, 1 reply; 4+ messages in thread
From: Runyu Xiao @ 2026-08-30 1:51 UTC (permalink / raw)
To: mario.limonciello
Cc: thomas.lendacky, john.allen, herbert, davem, linux-crypto,
linux-kernel, stable, runyu.xiao, jianhao.xu
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
Link: https://lore.kernel.org/all/20260829133410.1708684-1-runyu.xiao@seu.edu.cn/
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Assisted-by: Codex:GPT-5
---
v2:
- Move mutex initialization before setting up the misc device, as suggested
by Tom Lendacky.
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 410084a9039c..4db49a14550c 100644
--- a/drivers/crypto/ccp/dbc.c
+++ b/drivers/crypto/ccp/dbc.c
@@ -235,6 +235,8 @@ int dbc_dev_init(struct psp_device *psp)
goto cleanup_mbox;
}
+ mutex_init(&dbc_dev->ioctl_mutex);
+
dbc_dev->char_dev.minor = MISC_DYNAMIC_MINOR;
dbc_dev->char_dev.name = "dbc";
dbc_dev->char_dev.fops = &dbc_fops;
@@ -243,8 +245,6 @@ int dbc_dev_init(struct psp_device *psp)
if (ret)
goto cleanup_mbox;
- mutex_init(&dbc_dev->ioctl_mutex);
-
return 0;
cleanup_mbox:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] crypto: ccp: Initialize DBC ioctl mutex before registering device
2026-08-30 1:51 ` [PATCH v2] " Runyu Xiao
@ 2026-08-30 15:19 ` Tom Lendacky
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2026-08-30 15:19 UTC (permalink / raw)
To: Runyu Xiao, mario.limonciello
Cc: john.allen, herbert, davem, linux-crypto, linux-kernel, stable,
jianhao.xu
On 8/29/26 20:51, Runyu Xiao wrote:
> 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
> Link: https://lore.kernel.org/all/20260829133410.1708684-1-runyu.xiao@seu.edu.cn/
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> Assisted-by: Codex:GPT-5
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> v2:
> - Move mutex initialization before setting up the misc device, as suggested
> by Tom Lendacky.
>
> 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 410084a9039c..4db49a14550c 100644
> --- a/drivers/crypto/ccp/dbc.c
> +++ b/drivers/crypto/ccp/dbc.c
> @@ -235,6 +235,8 @@ int dbc_dev_init(struct psp_device *psp)
> goto cleanup_mbox;
> }
>
> + mutex_init(&dbc_dev->ioctl_mutex);
> +
> dbc_dev->char_dev.minor = MISC_DYNAMIC_MINOR;
> dbc_dev->char_dev.name = "dbc";
> dbc_dev->char_dev.fops = &dbc_fops;
> @@ -243,8 +245,6 @@ int dbc_dev_init(struct psp_device *psp)
> if (ret)
> goto cleanup_mbox;
>
> - mutex_init(&dbc_dev->ioctl_mutex);
> -
> return 0;
>
> cleanup_mbox:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-30 15:19 UTC | newest]
Thread overview: 4+ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®