From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Kees Cook <kees@kernel.org>,
"Darrick J . Wong" <djwong@kernel.org>,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH 1/2] lib/cmdline_kunit: add test case for memparse()
Date: Thu, 22 Jan 2026 17:25:51 +0200 [thread overview]
Message-ID: <aXJBf5mYUOFCli1P@smile.fi.intel.com> (raw)
In-Reply-To: <533de75be777940d591ea23a41d595c212667baa.camel@yandex.ru>
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
next prev parent reply other threads:[~2026-01-22 15:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 11:12 [PATCH 0/2] minor lib/cmdline enhancements Dmitry Antipov
2026-01-22 11:12 ` [PATCH 1/2] lib/cmdline_kunit: add test case for memparse() Dmitry Antipov
2026-01-22 11:46 ` Andy Shevchenko
2026-01-22 15:00 ` Dmitry Antipov
2026-01-22 15:25 ` Andy Shevchenko [this message]
2026-01-22 11:12 ` [PATCH 2/2] lib/cmdline: adjust a few comments to fix kernel-doc -Wreturn warnings Dmitry Antipov
2026-01-22 11:40 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXJBf5mYUOFCli1P@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=akpm@linux-foundation.org \
--cc=djwong@kernel.org \
--cc=dmantipov@yandex.ru \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox