[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202601071206.87F85EF2C@keescook>
Date: Wed, 7 Jan 2026 12:08:54 -0800
From: Kees Cook <kees@...nel.org>
To: Dmitry Antipov <dmantipov@...dex.ru>
Cc: Carlos Maiolino <cem@...nel.org>, Christoph Hellwig <hch@...radead.org>,
Andy Shevchenko <andy@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-xfs@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] lib: introduce simple error-checking wrapper for
memparse()
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);
--
Kees Cook
Powered by blists - more mailing lists