All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Baker <len.baker@gmx.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Len Baker <len.baker@gmx.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Iurii Zaikin <yzaikin@google.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sysctl: Avoid open coded arithmetic in memory allocator functions
Date: Sat, 23 Oct 2021 12:31:58 +0200	[thread overview]
Message-ID: <20211023103158.GA4145@titan> (raw)
In-Reply-To: <YWr7UN1+RkayVWy2@casper.infradead.org>

Hi Matthew,

On Sat, Oct 16, 2021 at 05:18:24PM +0100, Matthew Wilcox wrote:
> On Sat, Oct 16, 2021 at 05:28:28PM +0200, Len Baker wrote:
> > +static size_t new_dir_size(size_t namelen)
> > +{
> > +	size_t bytes;
> > +
> > +	if (check_add_overflow(sizeof(struct ctl_dir), sizeof(struct ctl_node),
> > +			       &bytes))
> > +		return SIZE_MAX;
> > +	if (check_add_overflow(bytes, array_size(sizeof(struct ctl_table), 2),
> > +			       &bytes))
> > +		return SIZE_MAX;
> > +	if (check_add_overflow(bytes, namelen, &bytes))
> > +		return SIZE_MAX;
> > +	if (check_add_overflow(bytes, (size_t)1, &bytes))
> > +		return SIZE_MAX;
> > +
> > +	return bytes;
> > +}
>
> I think this is overkill.  All these structs are small and namelen is
> supplied by the kernel, not specified by userspace.  It really complicates
> the code, and I don't see the advantage.
>
Ok, understood. I will send a v2 without this function.

Thanks for the review,
Len

      reply	other threads:[~2021-10-23 10:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16 15:28 [PATCH] sysctl: Avoid open coded arithmetic in memory allocator functions Len Baker
2021-10-16 16:18 ` Matthew Wilcox
2021-10-23 10:31   ` Len Baker [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=20211023103158.GA4145@titan \
    --to=len.baker@gmx.com \
    --cc=gustavoars@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=willy@infradead.org \
    --cc=yzaikin@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.