Linux Hardening
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: 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: Wed, 7 Jan 2026 12:08:54 -0800	[thread overview]
Message-ID: <202601071206.87F85EF2C@keescook> (raw)
In-Reply-To: <20260107183614.782245-1-dmantipov@yandex.ru>

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

  parent reply	other threads:[~2026-01-07 20:08 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 [this message]
2026-01-08  9:31   ` Christoph Hellwig

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=202601071206.87F85EF2C@keescook \
    --to=kees@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andy@kernel.org \
    --cc=cem@kernel.org \
    --cc=dmantipov@yandex.ru \
    --cc=hch@infradead.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