Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: fips - replace simple_strtol with kstrtoint to improve fips_enable

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>

authored by

Thorsten Blum and committed by
Herbert Xu
33eea63f 1a098379

+4 -1
+4 -1
crypto/fips.c
··· 24 24 /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */ 25 25 static int fips_enable(char *str) 26 26 { 27 - fips_enabled = !!simple_strtol(str, NULL, 0); 27 + if (kstrtoint(str, 0, &fips_enabled)) 28 + return 0; 29 + 30 + fips_enabled = !!fips_enabled; 28 31 pr_info("fips mode: %s\n", str_enabled_disabled(fips_enabled)); 29 32 return 1; 30 33 }