public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable
@ 2025-09-15 22:12 Thorsten Blum
  2025-10-17  8:16 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-09-15 22:12 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel

Replace simple_strtol() with the recommended kstrtoint() for parsing the
'fips=' boot parameter. Unlike simple_strtol(), which returns a long,
kstrtoint() converts the string directly to an integer and avoids
implicit casting.

Check the return value of kstrtoint() and reject invalid values. This
adds error handling while preserving existing behavior for valid values,
and removes use of the deprecated simple_strtol() helper.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 crypto/fips.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/crypto/fips.c b/crypto/fips.c
index e88a604cb42b..65d2bc070a26 100644
--- a/crypto/fips.c
+++ b/crypto/fips.c
@@ -24,7 +24,10 @@ EXPORT_SYMBOL_GPL(fips_fail_notif_chain);
 /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
 static int fips_enable(char *str)
 {
-	fips_enabled = !!simple_strtol(str, NULL, 0);
+	if (kstrtoint(str, 0, &fips_enabled))
+		return 0;
+
+	fips_enabled = !!fips_enabled;
 	pr_info("fips mode: %s\n", str_enabled_disabled(fips_enabled));
 	return 1;
 }
-- 
2.51.0


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

* Re: [PATCH] crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable
  2025-09-15 22:12 [PATCH] crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable Thorsten Blum
@ 2025-10-17  8:16 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2025-10-17  8:16 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: David S. Miller, linux-crypto, linux-kernel

On Tue, Sep 16, 2025 at 12:12:45AM +0200, Thorsten Blum wrote:
> Replace simple_strtol() with the recommended kstrtoint() for parsing the
> 'fips=' boot parameter. Unlike simple_strtol(), which returns a long,
> kstrtoint() converts the string directly to an integer and avoids
> implicit casting.
> 
> Check the return value of kstrtoint() and reject invalid values. This
> adds error handling while preserving existing behavior for valid values,
> and removes use of the deprecated simple_strtol() helper.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  crypto/fips.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

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

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

end of thread, other threads:[~2025-10-17  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 22:12 [PATCH] crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable Thorsten Blum
2025-10-17  8:16 ` Herbert Xu

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