From: Christoph Hellwig <hch@infradead.org>
To: Kees Cook <kees@kernel.org>
Cc: Dmitry Antipov <dmantipov@yandex.ru>,
Carlos Maiolino <cem@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Andy Shevchenko <andy@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-xfs@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] lib: introduce simple error-checking wrapper for memparse()
Date: Thu, 8 Jan 2026 01:31:51 -0800 [thread overview]
Message-ID: <aV95h8JyKvGkDfBw@infradead.org> (raw)
In-Reply-To: <202601071206.87F85EF2C@keescook>
On Wed, Jan 07, 2026 at 12:08:54PM -0800, Kees Cook wrote:
> On Wed, Jan 07, 2026 at 09:36:13PM +0300, Dmitry Antipov wrote:
> > Introduce 'memvalue()' which uses 'memparse()' to parse a string with
> > optional memory suffix into a number and returns this number or ULLONG_MAX
> > if the number is negative or an unrecognized character was encountered.
>
> ULLONG_MAX is a valid address, though. I don't like this as an error
> canary. How about using __must_check with 0/negative return value and
> put the parsed value into a passed-by-reference variable instead? This
> has the benefit of also performing type checking on the variable so that
> a returned value can never be truncated accidentally:
>
>
> int __must_check memvalue(const char *ptr, unsigned long long *addr);
That does sound pretty nice as an API. Should addr better be an
u64 instead of unsligned long long, though?
prev parent reply other threads:[~2026-01-08 9:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 18:36 [PATCH] lib: introduce simple error-checking wrapper for memparse() Dmitry Antipov
2026-01-07 18:36 ` [PATCH v2] xfs: adjust handling of a few numerical mount options Dmitry Antipov
2026-01-07 18:48 ` [PATCH] lib: introduce simple error-checking wrapper for memparse() Andrew Morton
2026-01-08 13:14 ` Dmitry Antipov
2026-01-07 19:22 ` Andy Shevchenko
2026-01-07 19:24 ` Andy Shevchenko
2026-01-07 20:08 ` Kees Cook
2026-01-08 9:31 ` Christoph Hellwig [this message]
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=aV95h8JyKvGkDfBw@infradead.org \
--to=hch@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=cem@kernel.org \
--cc=dmantipov@yandex.ru \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-xfs@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