All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Bernard Metzler <bernard.metzler@linux.dev>,
	rosenp@gmail.com, leon@kernel.org, gustavoars@kernel.org,
	linux-rdma@vger.kernel.org
Subject: Re: [RFC PATCH v3] RDMA/siw: use kzalloc_flex
Date: Thu, 14 May 2026 09:12:23 -0700	[thread overview]
Message-ID: <202605140906.EC4B0F5A@keescook> (raw)
In-Reply-To: <20260513142846.GN7702@ziepe.ca>

On Wed, May 13, 2026 at 11:28:46AM -0300, Jason Gunthorpe wrote:
> Ignore this, kxalloc_flex should not be assumed to initialize anything
> but 0. IDK why they put in the auto-initialize when it cannot be
> relied on, security in depth I guess.

Correct, manual initialization is still always required. The auto-init
(when counted_by is supported) is to deal with adding counted_by to code
that doesn't initialize the counter before access. i.e. this code used
to work:

thing = kzalloc(sizeof(*thing) + n * sizeof(*thing->fam));
access(thing->fam);
thing->fam_count = n;

but if we add counted_by and use kzalloc_flex, suddenly it breaks (at
access() time) unless kzalloc_flex also performs the "fam_count = n"
at alloc time.

-- 
Kees Cook

  reply	other threads:[~2026-05-14 16:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 14:11 [RFC PATCH v3] RDMA/siw: use kzalloc_flex bernard.metzler
2026-05-13 14:17 ` Bernard Metzler
2026-05-13 14:28   ` Jason Gunthorpe
2026-05-14 16:12     ` Kees Cook [this message]
2026-05-13 17:45 ` Leon Romanovsky
2026-05-14 13:14   ` Bernard Metzler
2026-05-17 14:52     ` Leon Romanovsky

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=202605140906.EC4B0F5A@keescook \
    --to=kees@kernel.org \
    --cc=bernard.metzler@linux.dev \
    --cc=gustavoars@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rosenp@gmail.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.