]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/slab: Plumb kmem_buckets into __do_kmalloc_node()
authorKees Cook <kees@kernel.org>
Mon, 1 Jul 2024 19:12:59 +0000 (12:12 -0700)
committerVlastimil Babka <vbabka@suse.cz>
Wed, 3 Jul 2024 10:24:19 +0000 (12:24 +0200)
commit67f2df3b82d091ed095d0e47e1f3a9d3e18e4e41
tree8684c170a63bb93ff6722114ac056f4974c2951d
parent72e0fe2241ce113cbba339ca8c2450b167774530
mm/slab: Plumb kmem_buckets into __do_kmalloc_node()

Introduce CONFIG_SLAB_BUCKETS which provides the infrastructure to
support separated kmalloc buckets (in the following kmem_buckets_create()
patches and future codetag-based separation). Since this will provide
a mitigation for a very common case of exploits, it is recommended to
enable this feature for general purpose distros. By default, the new
Kconfig will be enabled if CONFIG_SLAB_FREELIST_HARDENED is enabled (and
it is added to the hardening.config Kconfig fragment).

To be able to choose which buckets to allocate from, make the buckets
available to the internal kmalloc interfaces by adding them as the
second argument, rather than depending on the buckets being chosen from
the fixed set of global buckets. 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().

To avoid adding the extra argument when !CONFIG_SLAB_BUCKETS, only the
top-level macros and static inlines use the buckets argument (where
they are stripped out and compiled out respectively). The actual extern
functions can then be built without the argument, and the internals
fall back to the global kmalloc buckets unconditionally.

Co-developed-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
include/linux/slab.h
kernel/configs/hardening.config
mm/Kconfig
mm/slab.h
mm/slab_common.c
mm/slub.c
scripts/kernel-doc