Re: [PATCH v3 0/6] mm/slab: Support selecting slab hardening features at boot
From: Harry Yoo
Date: Fri Dec 04 2026 - 07:12:05 EST
On Sat, Nov 28, 2026 at 09:21:11PM -0800, Chris Down wrote:
> Hi Vlastimil,
>
> Vlastimil Babka (SUSE) writes:
> >I'm not thrilled about the "default to on". We usually do these features
> >opt-in. Now our distro kernel would likely need to have these "disable this"
> >options in the default command line, with documentation to remove it for a
> >hardened setup.
> >
> >But yeah doing it opt-in, the hardened setups would now have to start
> >passing the extra params to enable this, even if until now enabling the
> >config option was enough. Also not great, but we can argue they are still
> >the minority?
> >
> >Of course there's always the possibility of adding another _DEFAUT_ON
> >configs. Not great either. Sigh.
>
> Yes, it is ugly. Given that Harry asked for one of those [1], how about
> a single SLAB_HARDENING_DEFAULT_ON for both features in v4?
Revisiting my own proposal, the main reason why I suggested
*_DEFAULT_ON flags is because unconditionally compiling hardening
features could have measurable overhead e.g.) partitioned kmalloc
caches.
For SLAB_FREELIST_RANDOM and SLAB_FREELIST_HARDENED, unconditionally
compiling in the feature has negligible overhead so we could instead
let them determine default behaviour instead of introducing _DEFAULT_ON
configs.
For SLAB_BUCKETS, Vlastimil is working on making it less expensive to
enable at runtime (which is inspired by your series)
https://lore.kernel.org/linux-mm/20261203-kmalloc-entry-rework-v2-0-d718dc4fd906@xxxxxxxxxx
"If this is accepted, [1] should be rebased on it as it makes the
slab_buckets boot-time handling really straightforward. In fact
CONFIG_SLAB_BUCKETS could be repurposed to only control the default
behavior, while the code is always compiled in."
With that, SLAB_FREELIST_RANDOM, SLAB_FREELIST_HARDENED, SLAB_BUCKETS
could always be in compiled and repurposed to determine the default
behavior instead of *_DEFAULT_ON.
For KMALLOC_PARTITION_CACHES I don't have strong opinion on having
_DEFAULT_ON flag for this, but I'd argue it's fairly reasonable to
assume it's on by default when it's compiled in, as compiling in the
feature has _some_ overhead already.
With that and slab_hardening= boot parameter I don't have any further
concern to raise at the moment.
Does that sound good to you, Chris?
> The downside is that SLAB_BUCKETS defaults to
> SLAB_FREELIST_HARDENED, which this series makes default y, so a defconfig
> kernel would get the buckets built in and on at boot.
...with above we don't need to worry about this!
--
Cheers,
Harry / Hyeonggon