]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 15 Sep 2025 22:12:45 +0000 (00:12 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 17 Oct 2025 08:03:57 +0000 (16:03 +0800)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/fips.c

index e88a604cb42b5913167adfb01a55367ef3a3e3fc..65d2bc070a263638ae42ee91a90d415858074211 100644 (file)
@@ -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;
 }