From: Kees Cook <kees@kernel.org>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Vlastimil Babka <vbabka@suse.cz>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
linux-mm@kvack.org, linux-hardening@vger.kernel.org, "GONG,
Ruiqi" <gongruiqi@huaweicloud.com>,
Xiu Jianfeng <xiujianfeng@huawei.com>,
Suren Baghdasaryan <surenb@google.com>,
Jann Horn <jannh@google.com>,
Matteo Rizzo <matteorizzo@google.com>,
Thomas Graf <tgraf@suug.ch>,
Herbert Xu <herbert@gondor.apana.org.au>,
julien.voisin@dustri.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/6] mm/slab: Plumb kmem_buckets into __do_kmalloc_node()
Date: Fri, 31 May 2024 13:59:14 -0700 [thread overview]
Message-ID: <202405311355.B6EBA095@keescook> (raw)
In-Reply-To: <tkjmauxa4jigjznxp2ltxymz3u6urwuzwnbaaxmdg6ema7yf5a@fb2etkpyd4g4>
On Fri, May 31, 2024 at 12:51:29PM -0400, Kent Overstreet wrote:
> On Fri, May 31, 2024 at 09:48:49AM -0700, Kees Cook wrote:
> > On Fri, May 24, 2024 at 11:01:40AM -0400, Kent Overstreet wrote:
> > > On Wed, Apr 24, 2024 at 02:40:59PM -0700, Kees Cook wrote:
> > > > To be able to choose which buckets to allocate from, make the buckets
> > > > available to the lower level kmalloc interfaces by adding them as the
> > > > first argument. Where the bucket is not available, pass NULL, which means
> > > > "use the default system kmalloc bucket set" (the prior existing behavior),
> > > > as implemented in kmalloc_slab().
> > >
> > > I thought the plan was to use codetags for this? That would obviate the
> > > need for all this plumbing.
> > >
> > > Add fields to the alloc tag for:
> > > - allocation size (or 0 if it's not a compile time constant)
> > > - union of kmem_cache, kmem_buckets, depending on whether the
> > > allocation size is constant or not
> >
> > I want to provide "simple" (low-hanging fruit) coverage that can live
> > separately from the codetags-based coverage. The memory overhead for
> > this patch series is negligible, but I suspect the codetags expansion,
> > while not giant, will be more than some deployments will want. I want
> > to avoid an all-or-nothing solution -- which is why I had intended this
> > to be available "by default".
>
> technically there's no reason for your thing to depend on
> CONFIG_CODETAGGING at all, that's the infrastructure for finding
> codetags for e.g. /proc/allocinfo. you'd just be using the alloc_hoos()
> macro and struct alloc_tag as a place to stash the kmem_buckets pointer.
It's the overhead of separate kmem_cache and kmem_buckets for every
allocation location that I meant. So I'd like the "simple" version for
gaining coverage over the currently-being-regularly-exploited cases, and
then allow for the "big hammer" solution too.
However, I do think I'll still need the codetag infra because of the
sections, etc. I think we'll need to pre-build the caches, but maybe
that could be avoided by adding some kind of per-site READ_ONCE/lock
thingy to create them on demand. We'll see! :)
--
Kees Cook
next prev parent reply other threads:[~2024-05-31 20:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 21:40 [PATCH v3 0/6] slab: Introduce dedicated bucket allocator Kees Cook
2024-04-24 21:40 ` [PATCH v3 1/6] mm/slab: Introduce kmem_buckets typedef Kees Cook
2024-04-24 21:40 ` [PATCH v3 2/6] mm/slab: Plumb kmem_buckets into __do_kmalloc_node() Kees Cook
2024-05-24 13:38 ` Vlastimil Babka
2024-05-31 16:42 ` Kees Cook
2024-05-24 15:01 ` Kent Overstreet
2024-05-31 16:48 ` Kees Cook
2024-05-31 16:50 ` Kent Overstreet
2024-05-31 16:51 ` Kent Overstreet
2024-05-31 20:59 ` Kees Cook [this message]
2024-04-24 21:41 ` [PATCH v3 3/6] mm/slab: Introduce __kvmalloc_node() that can take kmem_buckets argument Kees Cook
2024-04-24 21:41 ` [PATCH v3 4/6] mm/slab: Introduce kmem_buckets_create() and family Kees Cook
2024-05-24 13:43 ` Vlastimil Babka
2024-05-31 16:37 ` Kees Cook
2024-04-24 21:41 ` [PATCH v3 5/6] ipc, msg: Use dedicated slab buckets for alloc_msg() Kees Cook
2024-04-24 21:41 ` [PATCH v3 6/6] mm/util: Use dedicated slab buckets for memdup_user() Kees Cook
2024-04-28 11:02 ` [PATCH v3 0/6] slab: Introduce dedicated bucket allocator jvoisin
2024-04-28 17:02 ` Kees Cook
2024-05-03 13:39 ` jvoisin
2024-05-03 19:06 ` Kees Cook
2024-05-24 14:54 ` Kent Overstreet
2024-05-31 16:39 ` Kees Cook
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=202405311355.B6EBA095@keescook \
--to=kees@kernel.org \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=gongruiqi@huaweicloud.com \
--cc=herbert@gondor.apana.org.au \
--cc=iamjoonsoo.kim@lge.com \
--cc=jannh@google.com \
--cc=julien.voisin@dustri.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matteorizzo@google.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=surenb@google.com \
--cc=tgraf@suug.ch \
--cc=vbabka@suse.cz \
--cc=xiujianfeng@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox