crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
Subsystems (2)
PATCH v2 1/1 crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
Replace the manual string copying and parsing logic with a call to simple_strtoull() to simplify and improve qat_uclo_parse_num().
Ensure that the parsed number does not exceed UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.
---
Changes in v2:
- Use simple_strtoull(), return -EINVAL, and guard against overflow as suggested by Andy
- Link to v1: https://lore.kernel.org/lkml/[email protected]/
--- drivers/crypto/intel/qat/qat_common/qat_uclo.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_uclo.c +5 -13
@@ -200,20 +200,12 @@ qat_uclo_cleanup_batch_init_list(struct icp_qat_fw_loader_handle *handle,static int qat_uclo_parse_num (char *str,unsigned int *num) { -char buf[16 ] = {0 }; -unsigned long ae =0 ; -int i; - -strscpy (buf, str,sizeof (buf)); -for (i =0 ; i <16 ; i++) { -if (!isdigit (buf[i])) { - buf[i] ='\0' ; -break ; - } - } -if ((kstrtoul (buf,10 , &ae))) -return -EFAULT ; +unsigned long long ae; +char *end; + ae =simple_strtoull (str, &end,10 ); +if (ae >UINT_MAX || str == end || (end - str) >19 ) +return -EINVAL ; *num = (unsigned int )ae;return 0 ; }
Signature · 1 line
2.51.0
Quoted 8 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.Signed-off-by Thorsten Blum <[email protected]>
Thanks,
Signature · 1 line
Giovanni
Quoted 6 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.
Reviewed-by; Andy Shevchenko <[email protected]>
Quoted 4 lines
---
Changes in v2:
- Usesimple_strtoull(), return-EINVAL, and guard against overflow as suggested by Andy
(some) overflows :-) But at least it keeps the code on par with the original.
And we ignore false positive (in this case!) checkpatch warning.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Giovanni Cabiddu
maintainerQuoted 9 lines · Andy Shevchenko
Quoted 6 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.Reviewed-by; Andy Shevchenko <[email protected]>
s/;/:
I just noticed this while applying the patch to my local tree.
Due to the typo, patchwork is not applying your tag [1].
[1] https://patchwork.kernel.org/project/linux-crypto/patch/[email protected]/mbox/
Regards,
Signature · 1 line
Giovanni
Quoted 9 lines · Giovanni Cabiddu
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.
Quoted 6 lines
Quoted 1 line
Reviewed-by; Andy Shevchenko <[email protected]>
s/;/:
I just noticed this while applying the patch to my local tree.
Due to the typo, patchwork is not applying your tag [1].
Oh, thanks for catching this. Have you added it manually or should I do something about it?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Giovanni Cabiddu
maintainerQuoted 11 lines · Andy Shevchenko
Quoted 10 lines · Giovanni Cabiddu
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.Reviewed-by; Andy Shevchenko <[email protected]>
Quoted 8 lines
Quoted 5 lines
s/;/:
I just noticed this while applying the patch to my local tree.
Due to the typo, patchwork is not applying your tag [1].
Oh, thanks for catching this. Have you added it manually or should I do something about it?
I haven't added it manually. If you reply with your tag again it will get sorted.
Thanks!
Signature · 1 line
Giovanni
Andy Shevchenko
Reviewed-byQuoted 10 lines · Giovanni Cabiddu
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Giovanni Cabiddu
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I just noticed this while applying the patch to my local tree.
Due to the typo, patchwork is not applying your tag [1].
Oh, thanks for catching this. Have you added it manually or should I do something about it?
I haven't added it manually. If you reply with your tag again it will get sorted.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Herbert Xu
maintainerQuoted 8 lines · Thorsten Blum
Replace the manual string copying and parsing logic with a call to
simple_strtoull()to simplify and improveqat_uclo_parse_num().Ensure that the parsed number does not exceed
UINT_MAX, and add an approximate upper-bound check (no more than 19 digits) to guard against overflow.Signed-off-by Thorsten Blum <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Usesimple_strtoull(), return-EINVAL, and guard against overflow as suggested by Andy
- Link to v1: https://lore.kernel.org/lkml/[email protected]/--- drivers/crypto/intel/qat/qat_common/qat_uclo.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt