On Thu, Jan 22, 2026 at 06:00:43PM +0300, Dmitry Antipov wrote:
> On Thu, 2026-01-22 at 13:46 +0200, Andy Shevchenko wrote:
>
> > Can we also have one with more than 20 decimal digits?
>
> Hmmm... running simple userspace test,
>
> strtoull("569202370375329612767", ...)
>
> returns ULLONG_MAX (and sets errno to -ERANGE), but
>
> memparse("569202370375329612767", ...)
>
> seems blindly overflows to -2646695909666487329.
>
> I'm strongly suspecting that 'memparse()' should be carefully
> tweaked to use 'kstrtoull()' instead of 'simple_strtoull()'.
It will require an intermediate buffer which your series is exactly against,
right? It's better to actually create a safe wrapper on top of
simple_strtoull().
The points are the following:
If there is a decimal base, we need to count leading 0:s.
Then add a check for how many characters were actually processed.
Partially something similar is done here:
drivers/crypto/intel/qat/qat_common/qat_uclo.c:206
--
With Best Regards,
Andy Shevchenko