* [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
@ 2025-10-26 1:57 Thorsten Blum
2025-10-27 8:47 ` Giovanni Cabiddu
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Thorsten Blum @ 2025-10-26 1:57 UTC (permalink / raw)
To: Giovanni Cabiddu, Herbert Xu, David S. Miller, Andy Shevchenko,
Jack Xu, Suman Kumar Chakraborty, Qianfeng Rong
Cc: Thorsten Blum, qat-linux, linux-crypto, linux-kernel
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.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Use simple_strtoull(), return -EINVAL, and guard against overflow as
suggested by Andy
- Link to v1: https://lore.kernel.org/lkml/20251022123622.349544-1-thorsten.blum@linux.dev/
---
drivers/crypto/intel/qat/qat_common/qat_uclo.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/crypto/intel/qat/qat_common/qat_uclo.c b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
index 18c3e4416dc5..06d49cb781ae 100644
--- a/drivers/crypto/intel/qat/qat_common/qat_uclo.c
+++ b/drivers/crypto/intel/qat/qat_common/qat_uclo.c
@@ -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;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-26 1:57 [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num Thorsten Blum
@ 2025-10-27 8:47 ` Giovanni Cabiddu
2025-10-27 9:02 ` Andy Shevchenko
2025-10-31 9:51 ` Herbert Xu
2 siblings, 0 replies; 8+ messages in thread
From: Giovanni Cabiddu @ 2025-10-27 8:47 UTC (permalink / raw)
To: Thorsten Blum
Cc: Herbert Xu, David S. Miller, Andy Shevchenko, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> 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.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Thanks,
--
Giovanni
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-26 1:57 [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num Thorsten Blum
2025-10-27 8:47 ` Giovanni Cabiddu
@ 2025-10-27 9:02 ` Andy Shevchenko
2025-10-30 11:27 ` Giovanni Cabiddu
2025-10-31 9:51 ` Herbert Xu
2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-10-27 9:02 UTC (permalink / raw)
To: Thorsten Blum
Cc: Giovanni Cabiddu, Herbert Xu, David S. Miller, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> 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.
Reviewed-by; Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> Changes in v2:
> - Use simple_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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-27 9:02 ` Andy Shevchenko
@ 2025-10-30 11:27 ` Giovanni Cabiddu
2025-10-30 14:03 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Giovanni Cabiddu @ 2025-10-30 11:27 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Thorsten Blum, Herbert Xu, David S. Miller, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Mon, Oct 27, 2025 at 11:02:16AM +0200, Andy Shevchenko wrote:
> On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> > 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.
>
> Reviewed-by; Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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/20251026015710.1368-1-thorsten.blum@linux.dev/mbox/
Regards,
--
Giovanni
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-30 11:27 ` Giovanni Cabiddu
@ 2025-10-30 14:03 ` Andy Shevchenko
2025-10-30 14:10 ` Giovanni Cabiddu
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-10-30 14:03 UTC (permalink / raw)
To: Giovanni Cabiddu
Cc: Thorsten Blum, Herbert Xu, David S. Miller, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Thu, Oct 30, 2025 at 11:27:37AM +0000, Giovanni Cabiddu wrote:
> On Mon, Oct 27, 2025 at 11:02:16AM +0200, Andy Shevchenko wrote:
> > On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> > > 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.
> >
> > Reviewed-by; Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 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?
> [1] https://patchwork.kernel.org/project/linux-crypto/patch/20251026015710.1368-1-thorsten.blum@linux.dev/mbox/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-30 14:03 ` Andy Shevchenko
@ 2025-10-30 14:10 ` Giovanni Cabiddu
2025-10-30 17:41 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Giovanni Cabiddu @ 2025-10-30 14:10 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Thorsten Blum, Herbert Xu, David S. Miller, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Thu, Oct 30, 2025 at 04:03:10PM +0200, Andy Shevchenko wrote:
> On Thu, Oct 30, 2025 at 11:27:37AM +0000, Giovanni Cabiddu wrote:
> > On Mon, Oct 27, 2025 at 11:02:16AM +0200, Andy Shevchenko wrote:
> > > On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> > > > 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.
> > >
> > > Reviewed-by; Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 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!
--
Giovanni
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-30 14:10 ` Giovanni Cabiddu
@ 2025-10-30 17:41 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-10-30 17:41 UTC (permalink / raw)
To: Giovanni Cabiddu
Cc: Thorsten Blum, Herbert Xu, David S. Miller, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Thu, Oct 30, 2025 at 02:10:15PM +0000, Giovanni Cabiddu wrote:
> On Thu, Oct 30, 2025 at 04:03:10PM +0200, Andy Shevchenko wrote:
> > On Thu, Oct 30, 2025 at 11:27:37AM +0000, Giovanni Cabiddu wrote:
> > > On Mon, Oct 27, 2025 at 11:02:16AM +0200, Andy Shevchenko wrote:
> > > > On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> > > > > 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.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > 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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num
2025-10-26 1:57 [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num Thorsten Blum
2025-10-27 8:47 ` Giovanni Cabiddu
2025-10-27 9:02 ` Andy Shevchenko
@ 2025-10-31 9:51 ` Herbert Xu
2 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2025-10-31 9:51 UTC (permalink / raw)
To: Thorsten Blum
Cc: Giovanni Cabiddu, David S. Miller, Andy Shevchenko, Jack Xu,
Suman Kumar Chakraborty, Qianfeng Rong, qat-linux, linux-crypto,
linux-kernel
On Sun, Oct 26, 2025 at 02:57:07AM +0100, Thorsten Blum wrote:
> 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.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> Changes in v2:
> - Use simple_strtoull(), return -EINVAL, and guard against overflow as
> suggested by Andy
> - Link to v1: https://lore.kernel.org/lkml/20251022123622.349544-1-thorsten.blum@linux.dev/
> ---
> drivers/crypto/intel/qat/qat_common/qat_uclo.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
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] 8+ messages in thread
end of thread, other threads:[~2025-10-31 9:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-26 1:57 [PATCH v2] crypto: qat - use simple_strtoull to improve qat_uclo_parse_num Thorsten Blum
2025-10-27 8:47 ` Giovanni Cabiddu
2025-10-27 9:02 ` Andy Shevchenko
2025-10-30 11:27 ` Giovanni Cabiddu
2025-10-30 14:03 ` Andy Shevchenko
2025-10-30 14:10 ` Giovanni Cabiddu
2025-10-30 17:41 ` Andy Shevchenko
2025-10-31 9:51 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).