Skip to contentSkip to conversation

mm/slab: Support selecting slab hardening features at boot

PATCH Superseded Chris Down 3 participants 20 messages Oct 29 – Nov 13

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chris Down

author
#0 lore raw

v2 cover mm/slab: Support selecting slab hardening features at boot

Slab hardening settings are currently all build time choices. This means that, unfortunately, hosts with different requirements end up needing separate kernel images. At Meta, for example, some hosts are built with these options and the rest of the fleet isn't, and that's one of the things that keeps those kernels apart.

Following the discussion on v1, this series now does two things:

- SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM are cheap enough with sheaves that it makes more sense to just enable them by default than to make them switchable. With both on, system level benchmarks didn't change measurably, only slowpath heavy microbenchmarks did [1].

- SLAB_BUCKETS and KMALLOC_PARTITION_CACHES cost memory (Harry measured about 1 MiB and 18 MiB respectively after boot on a 64 CPU VM [2]), so they get slab_buckets= and kmalloc_partition= boot parameters, which default to on when the option is built in.

Changes in v2:
- Make SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM default y instead of adding boot parameters for them (Vlastimil).
- Skip the memdup_user() part of the slab_buckets test on !MMU (Sashiko).
- Keep slab_buckets= and kmalloc_partition= separate for now. We can discuss whether to merge them into slab_hardening= or similar, as Harry suggested.

v1: https://lore.kernel.org/r/[email protected]

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]

Chris Down (6):
mm/slab: Enable SLAB_FREELIST_HARDENED by default mm/slab: Enable SLAB_FREELIST_RANDOM by default mm/slab: Support disabling SLAB_BUCKETS at boot
slub_kunit: Add a test for the slab_buckets boot parameter mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot
slub_kunit: Add a test for the kmalloc_partition boot parameter

 .../admin-guide/kernel-parameters.txt         | 15 ++++
 lib/tests/slub_kunit.c                        | 87 +++++++++++++++++++
 mm/Kconfig                                    | 11 +++
 mm/slab.h                                     |  8 ++
 mm/slab_common.c                              | 48 ++++++++--
 5 files changed, 163 insertions(+), 6 deletions(-)

base-commit: d15d7703166daf7bd62c844a3cb1b3a6279adb4c

Signature · 1 line
2.54.0
author
#1 lore raw

PATCH v2 1/6 mm/slab: Enable SLAB_FREELIST_HARDENED by default

SLAB_FREELIST_HARDENED obfuscates the free pointers stored in free objects, and catches naive double frees and frees to the wrong cache. Most distros already enable it, and with sheaves its cost is small, since the per-cpu fast paths don't touch freelists. Measurements also show this quite clearly [1][2].

So let's just enable it by default. SLAB_BUCKETS defaults to SLAB_FREELIST_HARDENED, so it's now enabled by default too.

---
 mm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
mm/Kconfig +1 -0
index 604c58199acb..17d017e8fbef 100644
@@ -208,6 +208,7 @@ config SLAB_FREELIST_RANDOM
 config SLAB_FREELIST_HARDENED
 	bool "Harden slab freelist metadata"
 	depends on !SLUB_TINY
+	default y
 	help
 	  Many kernel heap attacks try to target slab cache metadata and
 	  other infrastructure. This options makes minor performance
Signature · 1 line
2.54.0
Reviewed-by on v2 1/6
#2 lore raw

Re: [PATCH v2 1/6] mm/slab: Enable SLAB_FREELIST_HARDENED by default

Quoted 6 lines · Chris Down

SLAB_FREELIST_HARDENED obfuscates the free pointers stored in free objects, and catches naive double frees and frees to the wrong cache. Most distros already enable it, and with sheaves its cost is small, since the per-cpu fast paths don't touch freelists. Measurements also show this quite clearly [1][2].

Quoted 7 lines

So let's just enable it by default. SLAB_BUCKETS defaults to SLAB_FREELIST_HARDENED, so it's now enabled by default too.

Like I've always wanted it. :)

Signature · 1 line
Kees Cook
author
#3 lore raw

PATCH v2 2/6 mm/slab: Enable SLAB_FREELIST_RANDOM by default

In reply to Chris Down

SLAB_FREELIST_RANDOM randomises the order in which the objects in a new slab are handed out. Like SLAB_FREELIST_HARDENED, most distros already enable it, and its cost is only paid when a new slab is set up.

With it on, the same system level benchmarks didn't change measurably. Allocating from new slabs does get slower, by up to about 30% per object in a microbenchmark which does little else.

So let's enable it by default too. SHUFFLE_PAGE_ALLOCATOR defaults to SLAB_FREELIST_RANDOM && ACPI_NUMA, so it's now built in by default on those systems, but page shuffling itself stays off unless it's enabled with page_alloc.shuffle.

---
 mm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
mm/Kconfig +1 -0
index 17d017e8fbef..92ff97ff24fb 100644
@@ -200,6 +200,7 @@ config SLAB_MERGE_DEFAULT
 config SLAB_FREELIST_RANDOM
 	bool "Randomize slab freelist"
 	depends on !SLUB_TINY
+	default y
 	help
 	  Randomizes the freelist order used on creating new pages. This
 	  security feature reduces the predictability of the kernel slab
Signature · 1 line
2.54.0
Reviewed-by on v2 2/6
#4 lore raw

Re: [PATCH v2 2/6] mm/slab: Enable SLAB_FREELIST_RANDOM by default

Quoted 8 lines · Chris Down

SLAB_FREELIST_RANDOM randomises the order in which the objects in a new slab are handed out. Like SLAB_FREELIST_HARDENED, most distros already enable it, and its cost is only paid when a new slab is set up.

With it on, the same system level benchmarks didn't change measurably. Allocating from new slabs does get slower, by up to about 30% per object in a microbenchmark which does little else.

Quoted 7 lines

So let's enable it by default too. SHUFFLE_PAGE_ALLOCATOR defaults to SLAB_FREELIST_RANDOM && ACPI_NUMA, so it's now built in by default on those systems, but page shuffling itself stays off unless it's enabled with page_alloc.shuffle.

Again, just like it should be. I wonder, though, don't these 2 changes undercut the goal of making these boot-time selectable?

Signature · 1 line
Kees Cook
author
#5 lore raw

Re: [PATCH v2 2/6] mm/slab: Enable SLAB_FREELIST_RANDOM by default

Hi Kees,

Quoted 2 lines · Kees Cook

Again, just like it should be. I wonder, though, don't these 2 changes undercut the goal of making these boot-time selectable?

I don't think so. The goal is to stop needing separate images for hosts with different needs. It was never to make every option switchable for its own sake. For these two, the only real argument for leaving them out was CPU cost, and with sheaves that cost doesn't show up at the system level [1]. So turning them on everywhere removes the reason to build without them at all. Anyone who still wants them off can still say n at build time.

SLAB_BUCKETS and KMALLOC_PARTITION_CACHES are different. Their cost is memory, which is real and doesn't go away with sheaves, so those are the ones where a boot time switch makes sense.

[1] https://lore.kernel.org/r/[email protected]

Thanks for the review!

Chris

author
#6 lore raw

PATCH v2 3/6 mm/slab: Support disabling SLAB_BUCKETS at boot

In reply to Chris Down

SLAB_BUCKETS gives allocations with user-controlled size and contents, like memdup_user() and msg_msg, their own set of kmalloc caches, at the cost of the memory for those caches. It can only be chosen at build time, so hosts which want it and hosts which would rather not pay for it need separate kernels.

Add a slab_buckets= early parameter, enabled by default on kernels built with CONFIG_SLAB_BUCKETS=y, so that it can be turned off at boot.

---
 .../admin-guide/kernel-parameters.txt         |  8 ++++++
 mm/Kconfig                                    |  4 +++
 mm/slab_common.c                              | 26 +++++++++++++++----
 3 files changed, 33 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +8 -0
index 68647ff4bdd2..de2fd6963a16 100644
@@ -7001,6 +7001,14 @@ Kernel parameters
 			apic=verbose is specified.
 			Example: apic=debug show_lapic=all
 
+	slab_buckets= [MM,EARLY]
+			Format: <bool>
+			Enable or disable separate kmalloc buckets on kernels
+			built with CONFIG_SLAB_BUCKETS=y. When disabled,
+			allocations use regular kmalloc caches. Ignored
+			without that option.
+			Default: on.
+
 	slab_debug[=options[,slabs][;[options[,slabs]]...]]	[MM]
 			Enabling slab_debug allows one to determine the
 			culprit if slab objects become corrupted. Enabling
mm/Kconfig +4 -0
index 92ff97ff24fb..48078c1fd26f 100644
@@ -231,6 +231,10 @@ config SLAB_BUCKETS
 	  of extra pages since the bulk of user-controlled allocations
 	  are relatively long-lived.
 
+	  The separate buckets can be disabled at boot with the
+	  "slab_buckets=0" kernel parameter, in which case these
+	  allocations use the regular kmalloc caches.
+
 	  If unsure, say Y.
 
 config SLUB_STATS
mm/slab_common.c +21 -5
index e66c0778ee98..b7a46c368ab1 100644
@@ -410,6 +410,16 @@ EXPORT_SYMBOL(__kmem_cache_create_args);
 
 static struct kmem_cache *kmem_buckets_cache __ro_after_init;
 
+static bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+
+#ifdef CONFIG_SLAB_BUCKETS
+static int __init setup_slab_buckets(char *str)
+{
+	return kstrtobool(str, &slab_buckets_enabled);
+}
+early_param("slab_buckets", setup_slab_buckets);
+#endif
+
 /**
  * kmem_buckets_create - Create a set of caches that handle dynamic sized
  *			 allocations via kmem_buckets_alloc()
@@ -424,10 +434,12 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;
  *
  * Context: Cannot be called within an interrupt, but can be interrupted.
  *
- * Return: a pointer to the cache on success, NULL on failure. When
- * CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
- * subsequent calls to kmem_buckets_alloc() will fall back to kmalloc().
- * (i.e. callers only need to check for NULL on failure.)
+ * Return: a pointer to the cache on success, NULL on failure or when the
+ * separate buckets were disabled with the "slab_buckets=0" boot parameter.
+ * When CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned. In all
+ * of these cases subsequent calls to kmem_buckets_alloc() with the returned
+ * value fall back to kmalloc(), so callers that can live without separate
+ * buckets do not need to check the return value.
  */
 kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags,
 				  unsigned int useroffset,
@@ -448,6 +460,10 @@ kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags,
 	if (!IS_ENABLED(CONFIG_SLAB_BUCKETS))
 		return ZERO_SIZE_PTR;
 
+	/* NULL makes kmalloc_slab() use the regular kmalloc caches. */
+	if (!slab_buckets_enabled)
+		return NULL;
+
 	if (WARN_ON(!kmem_buckets_cache))
 		return NULL;
 
@@ -1059,7 +1075,7 @@ void __init create_kmalloc_caches(void)
 	/* Kmalloc array is now usable */
 	slab_state = UP;
 
-	if (IS_ENABLED(CONFIG_SLAB_BUCKETS))
+	if (IS_ENABLED(CONFIG_SLAB_BUCKETS) && slab_buckets_enabled)
 		kmem_buckets_cache = kmem_cache_create("kmalloc_buckets",
 						       sizeof(kmem_buckets),
 						       0, SLAB_NO_MERGE, NULL);
Signature · 1 line
2.54.0
#7 lore raw

Re: [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot

Quoted 8 lines · Chris Down

SLAB_BUCKETS gives allocations with user-controlled size and contents, like memdup_user() and msg_msg, their own set of kmalloc caches, at the cost of the memory for those caches. It can only be chosen at build time, so hosts which want it and hosts which would rather not pay for it need separate kernels.

Add a slab_buckets= early parameter, enabled by default on kernels built with CONFIG_SLAB_BUCKETS=y, so that it can be turned off at boot.

I thought the issue here was about calling convention (i.e. with CONFIG_SLAB_BUCKETS Vlastimil had suggested making the argument lists for the call chain shorter by dropping the bucket argument entirely).

Quoted 81 lines
---
 .../admin-guide/kernel-parameters.txt         |  8 ++++++
 mm/Kconfig                                    |  4 +++
 mm/slab_common.c                              | 26 +++++++++++++++----
 3 files changed, 33 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +8 -0
index 68647ff4bdd2..de2fd6963a16 100644
@@ -7001,6 +7001,14 @@ Kernel parameters
 			apic=verbose is specified.
 			Example: apic=debug show_lapic=all
 
+	slab_buckets= [MM,EARLY]
+			Format: <bool>
+			Enable or disable separate kmalloc buckets on kernels
+			built with CONFIG_SLAB_BUCKETS=y. When disabled,
+			allocations use regular kmalloc caches. Ignored
+			without that option.
+			Default: on.
+
 	slab_debug[=options[,slabs][;[options[,slabs]]...]]	[MM]
 			Enabling slab_debug allows one to determine the
 			culprit if slab objects become corrupted. Enabling
mm/Kconfig +4 -0
index 92ff97ff24fb..48078c1fd26f 100644
@@ -231,6 +231,10 @@ config SLAB_BUCKETS
 	  of extra pages since the bulk of user-controlled allocations
 	  are relatively long-lived.
 
+	  The separate buckets can be disabled at boot with the
+	  "slab_buckets=0" kernel parameter, in which case these
+	  allocations use the regular kmalloc caches.
+
 	  If unsure, say Y.
 
 config SLUB_STATS
mm/slab_common.c +16 -4
index e66c0778ee98..b7a46c368ab1 100644
@@ -410,6 +410,16 @@ EXPORT_SYMBOL(__kmem_cache_create_args);
 
 static struct kmem_cache *kmem_buckets_cache __ro_after_init;
 
+static bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+
+#ifdef CONFIG_SLAB_BUCKETS
+static int __init setup_slab_buckets(char *str)
+{
+	return kstrtobool(str, &slab_buckets_enabled);
+}
+early_param("slab_buckets", setup_slab_buckets);
+#endif
+
 /**
  * kmem_buckets_create - Create a set of caches that handle dynamic sized
  *			 allocations via kmem_buckets_alloc()
@@ -424,10 +434,12 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;
  *
  * Context: Cannot be called within an interrupt, but can be interrupted.
  *
- * Return: a pointer to the cache on success, NULL on failure. When
- * CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
- * subsequent calls to kmem_buckets_alloc() will fall back to kmalloc().
- * (i.e. callers only need to check for NULL on failure.)
+ * Return: a pointer to the cache on success, NULL on failure or when the
+ * separate buckets were disabled with the "slab_buckets=0" boot parameter.
+ * When CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned. In all
+ * of these cases subsequent calls to kmem_buckets_alloc() with the returned
+ * value fall back to kmalloc(), so callers that can live without separate
+ * buckets do not need to check the return value.
  */
 kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags,
 				  unsigned int useroffset,

mm/slab_common.c kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags, · line 465

Quoted 6 lines
mm/slab_common.c +3 -0
@@ -448,6 +460,10 @@ kmem_buckets *kmem_buckets_create(const char *name, slab_flags_t flags,
 	if (!IS_ENABLED(CONFIG_SLAB_BUCKETS))
 		return ZERO_SIZE_PTR;
 
+	/* NULL makes kmalloc_slab() use the regular kmalloc caches. */
+	if (!slab_buckets_enabled)
+		return NULL;

Regardless, I still prefer this being a static branch so we don't end up with a needless rodata global check.

Quoted 16 lines
mm/slab_common.c +2 -1
+
 	if (WARN_ON(!kmem_buckets_cache))
 		return NULL;
 
@@ -1059,7 +1075,7 @@ void __init create_kmalloc_caches(void)
 	/* Kmalloc array is now usable */
 	slab_state = UP;
 
-	if (IS_ENABLED(CONFIG_SLAB_BUCKETS))
+	if (IS_ENABLED(CONFIG_SLAB_BUCKETS) && slab_buckets_enabled)
 		kmem_buckets_cache = kmem_cache_create("kmalloc_buckets",
 						       sizeof(kmem_buckets),
 						       0, SLAB_NO_MERGE, NULL);
Signature · 1 line
2.54.0
Signature · 1 line
Kees Cook
maintainer
#8 lore raw

Re: [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot

A gentle ping to Kees to hear his thoughts on having a bit more coarse grained boot parameter e.g.) slab_hardening= to specify how much performance/memory is worth sacrificing for enhanced security.

Quoted 22 lines · Quoting an email from [1], Harry Yoo wrote:
Quoted 13 lines · Chris Down
Quoted 12 lines · Harry Yoo

If we end up supporting boot-time parameters for hardening, I think it should be all enabled (or disabled) by:

slab_hardening=none|light|full

 # please feel free to suggest bertter names

none: "Turn of all of them to maximize performance"

light: "I'm willying to sacrifice _some_ memory and CPU for security"

full: "I'm willying to sacrifice more overhead for security

Quoted 7 lines
Quoted 1 line

IMHO more fine-grained knob for each feature doesn't make much sense.

I think if we did the 4 knobs that is a good idea. Given now it's two, I think it seems reasonable to keep it as two separate knobs unless you object? Otherwise I think given it will only cover the latter two, it should be something like kmalloc_isolation= instead. Let me know what you think.

Quoted 5 lines

There has been constant, steady efforts to add more and more hardening features over the last decade. So I'd say slab_hardening= is more future proof :-)

Kees or Marco might have more insights on this.

[1] https://lore.kernel.org/linux-mm/auIVIKxjrdXIaUIY@thinkstation

Signature · 2 lines
Cheers,
Harry / Hyeonggon
author
#9 lore raw

Re: [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot

Hi Harry,

Quoted 3 lines · Harry Yoo

A gentle ping to Kees to hear his thoughts on having a bit more coarse grained boot parameter e.g.) slab_hardening= to specify how much performance/memory is worth sacrificing for enhanced security.

For what it's worth, I'd still prefer to keep slab_buckets= and kmalloc_partition= as they are. Each one maps onto one config option and one cost that you can reason about on its own (about 1 MiB vs 18 MiB in your numbers). If we want slab_hardening= as well, it seems easy enough to add later on top, as a way to set the defaults for the individual parameters. So I don't think it needs to block this.

I'd like to hear what Kees and Marco think too, though.

Thanks!

Chris

author
#10 lore raw

Re: [PATCH v2 3/6] mm/slab: Support disabling SLAB_BUCKETS at boot

In reply to Kees Cook

Hi Kees,

Quoted 3 lines · Kees Cook

I thought the issue here was about calling convention (i.e. with CONFIG_SLAB_BUCKETS Vlastimil had suggested making the argument lists for the call chain shorter by dropping the bucket argument entirely).

I think you might be thinking of Harry's kmalloc_params idea from the slab_alloc_context thread [1], which would fold the bucket and token arguments into one struct. That's a separate thing. This patch can't change the calling convention: with slab_buckets=0 the kmem_buckets argument is still passed down, it's just NULL, so kmalloc_slab() picks the normal caches.

What this patch is about is being able to build one image with CONFIG_SLAB_BUCKETS=y and not pay for the separate caches on hosts which don't want them. Harry measured that at about 1 MiB after boot [2], so it's the smaller of the two, but it's the same "needs a separate kernel" problem as kmalloc_partition=.

Quoted 2 lines

Regardless, I still prefer this being a static branch so we don't end up with a needless rodata global check.

The flag is only read in kmem_buckets_create() and create_kmalloc_caches(), when a set of buckets is created. It isn't read on the allocation path. Allocations never look at it: they just get the NULL that kmem_buckets_create() returned. So a static key wouldn't save anything at runtime. Also, some architectures (arm, for example) parse early params before jump_label_init(). So we'd still need the bool, and would have to flip the key later as init_on_alloc does.

Is there somewhere else you had in mind for it?

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]

Thanks!

Chris

author
#11 lore raw

PATCH v2 4/6 slub_kunit: Add a test for the slab_buckets boot parameter

In reply to Chris Down

Check that memdup_user() allocates from the memdup_user buckets by default, and from the regular kmalloc caches when they're turned off with slab_buckets=0.

---
 lib/tests/slub_kunit.c | 41 +++++++++++++++++++++++++++++++++++++++++
 mm/slab.h              |  4 ++++
 mm/slab_common.c       |  4 +++-
 3 files changed, 48 insertions(+), 1 deletion(-)
lib/tests/slub_kunit.c +41 -0
index e3b63f0338d5..670645875b27 100644
@@ -9,6 +9,8 @@
 #include <linux/delay.h>
 #include <linux/perf_event.h>
 #include <linux/kprobes.h>
+#include <linux/mman.h>
+#include <linux/string.h>
 #include "../mm/slab.h"
 
 static struct kunit_resource resource;
@@ -296,6 +298,41 @@ static void test_krealloc_redzone_zeroing(struct kunit *test)
 	kmem_cache_destroy(s);
 }
 
+#ifdef CONFIG_SLAB_BUCKETS
+static void test_slab_buckets(struct kunit *test)
+{
+	unsigned long user_addr;
+	const char *name;
+	void *p;
+
+	if (!slab_buckets_enabled)
+		KUNIT_EXPECT_NULL(test, kmem_buckets_create("TestSlub_buckets",
+							    0, 0, INT_MAX, NULL));
+
+	if (!IS_ENABLED(CONFIG_MMU))
+		kunit_skip(test, "userspace allocation needs an MMU");
+
+	user_addr = kunit_vm_mmap(test, NULL, 0, PAGE_SIZE,
+				  PROT_READ | PROT_WRITE,
+				  MAP_ANONYMOUS | MAP_PRIVATE, 0);
+	KUNIT_ASSERT_NE_MSG(test, user_addr, 0, "Could not create userspace mm");
+	KUNIT_ASSERT_LT_MSG(test, user_addr, (unsigned long)TASK_SIZE,
+			    "Failed to allocate user memory");
+
+	p = memdup_user((void __user *)user_addr, 64);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, p);
+
+	name = virt_to_slab(p)->slab_cache->name;
+	if (slab_buckets_enabled)
+		KUNIT_EXPECT_TRUE_MSG(test, strstarts(name, "memdup_user-"),
+				      "allocated from %s", name);
+	else
+		KUNIT_EXPECT_TRUE_MSG(test, strstarts(name, "kmalloc-"),
+				      "allocated from %s", name);
+	kfree(p);
+}
+#endif
+
 #if defined(CONFIG_PERF_EVENTS) || (defined(CONFIG_KPROBES) && defined(CONFIG_SMP))
 #define NR_ITERATIONS 1000
 #define NR_OBJECTS 1000
@@ -489,6 +526,9 @@ static struct kunit_case test_cases[] = {
 	KUNIT_CASE(test_kfree_rcu_wq_destroy),
 	KUNIT_CASE(test_leak_destroy),
 	KUNIT_CASE(test_krealloc_redzone_zeroing),
+#ifdef CONFIG_SLAB_BUCKETS
+	KUNIT_CASE(test_slab_buckets),
+#endif
 #ifdef CONFIG_PERF_EVENTS
 	KUNIT_CASE_SLOW(test_kmalloc_nolock_and_friends_perf),
 #endif
@@ -505,5 +545,6 @@ static struct kunit_suite test_suite = {
 };
 kunit_test_suite(test_suite);
 
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
 MODULE_DESCRIPTION("Kunit tests for slub allocator");
 MODULE_LICENSE("GPL");
mm/slab.h +4 -0
index e94ac63d10dc..b5b344d6e402 100644
@@ -390,6 +390,10 @@ extern struct list_head slab_caches;
 /* The slab cache that manages slab cache information */
 extern struct kmem_cache *kmem_cache;
 
+#if IS_ENABLED(CONFIG_KUNIT)
+extern bool slab_buckets_enabled;
+#endif
+
 /* A table of kmalloc cache names and sizes */
 extern const struct kmalloc_info_struct {
 	const char *name[NR_KMALLOC_TYPES];
mm/slab_common.c +3 -1
index b7a46c368ab1..9fe48da12010 100644
@@ -29,6 +29,7 @@
 #include <linux/memcontrol.h>
 #include <linux/stackdepot.h>
 #include <trace/events/rcu.h>
+#include <kunit/visibility.h>
 
 #include "../kernel/rcu/rcu.h"
 #include "internal.h"
@@ -410,7 +411,8 @@ EXPORT_SYMBOL(__kmem_cache_create_args);
 
 static struct kmem_cache *kmem_buckets_cache __ro_after_init;
 
-static bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+VISIBLE_IF_KUNIT bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+EXPORT_SYMBOL_IF_KUNIT(slab_buckets_enabled);
 
 #ifdef CONFIG_SLAB_BUCKETS
 static int __init setup_slab_buckets(char *str)
Signature · 1 line
2.54.0
#12 lore raw

Re: [PATCH v2 4/6] slub_kunit: Add a test for the slab_buckets boot parameter

Quoted 25 lines · Chris Down

Check that memdup_user() allocates from the memdup_user buckets by default, and from the regular kmalloc caches when they're turned off with slab_buckets=0.

---
 lib/tests/slub_kunit.c | 41 +++++++++++++++++++++++++++++++++++++++++
 mm/slab.h              |  4 ++++
 mm/slab_common.c       |  4 +++-
 3 files changed, 48 insertions(+), 1 deletion(-)
lib/tests/slub_kunit.c +2 -0
index e3b63f0338d5..670645875b27 100644
@@ -9,6 +9,8 @@
 #include <linux/delay.h>
 #include <linux/perf_event.h>
 #include <linux/kprobes.h>
+#include <linux/mman.h>
+#include <linux/string.h>
 #include "../mm/slab.h"
 
 static struct kunit_resource resource;

lib/tests/slub_kunit.c static void test_krealloc_redzone_zeroing(struct kunit *test) · line 301

Quoted 4 lines
lib/tests/slub_kunit.c +1 -0
@@ -296,6 +298,41 @@ static void test_krealloc_redzone_zeroing(struct kunit *test)
 	kmem_cache_destroy(s);
 }
 
+#ifdef CONFIG_SLAB_BUCKETS

Please don't ifdef to drop a test. If you have to do any ifdef, use it for test skipping instead.

Quoted 59 lines
lib/tests/slub_kunit.c +38 -0
+static void test_slab_buckets(struct kunit *test)
+{
+	unsigned long user_addr;
+	const char *name;
+	void *p;
+
+	if (!slab_buckets_enabled)
+		KUNIT_EXPECT_NULL(test, kmem_buckets_create("TestSlub_buckets",
+							    0, 0, INT_MAX, NULL));
+
+	if (!IS_ENABLED(CONFIG_MMU))
+		kunit_skip(test, "userspace allocation needs an MMU");
+
+	user_addr = kunit_vm_mmap(test, NULL, 0, PAGE_SIZE,
+				  PROT_READ | PROT_WRITE,
+				  MAP_ANONYMOUS | MAP_PRIVATE, 0);
+	KUNIT_ASSERT_NE_MSG(test, user_addr, 0, "Could not create userspace mm");
+	KUNIT_ASSERT_LT_MSG(test, user_addr, (unsigned long)TASK_SIZE,
+			    "Failed to allocate user memory");
+
+	p = memdup_user((void __user *)user_addr, 64);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, p);
+
+	name = virt_to_slab(p)->slab_cache->name;
+	if (slab_buckets_enabled)
+		KUNIT_EXPECT_TRUE_MSG(test, strstarts(name, "memdup_user-"),
+				      "allocated from %s", name);
+	else
+		KUNIT_EXPECT_TRUE_MSG(test, strstarts(name, "kmalloc-"),
+				      "allocated from %s", name);
+	kfree(p);
+}
+#endif
+
 #if defined(CONFIG_PERF_EVENTS) || (defined(CONFIG_KPROBES) && defined(CONFIG_SMP))
 #define NR_ITERATIONS 1000
 #define NR_OBJECTS 1000
@@ -489,6 +526,9 @@ static struct kunit_case test_cases[] = {
 	KUNIT_CASE(test_kfree_rcu_wq_destroy),
 	KUNIT_CASE(test_leak_destroy),
 	KUNIT_CASE(test_krealloc_redzone_zeroing),
+#ifdef CONFIG_SLAB_BUCKETS
+	KUNIT_CASE(test_slab_buckets),
+#endif
 #ifdef CONFIG_PERF_EVENTS
 	KUNIT_CASE_SLOW(test_kmalloc_nolock_and_friends_perf),
 #endif
@@ -505,5 +545,6 @@ static struct kunit_suite test_suite = {
 };
 kunit_test_suite(test_suite);
 
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
 MODULE_DESCRIPTION("Kunit tests for slub allocator");
 MODULE_LICENSE("GPL");
mm/slab.h +0 -0
index e94ac63d10dc..b5b344d6e402 100644

mm/slab.h extern struct list_head slab_caches; · line 395

Quoted 6 lines
mm/slab.h +3 -0
@@ -390,6 +390,10 @@ extern struct list_head slab_caches;
 /* The slab cache that manages slab cache information */
 extern struct kmem_cache *kmem_cache;
 
+#if IS_ENABLED(CONFIG_KUNIT)
+extern bool slab_buckets_enabled;
+#endif

This feels messy. Any reason not to just export it entirely and avoid all the ifdefness?

Quoted 29 lines
mm/slab.h +1 -0
+
 /* A table of kmalloc cache names and sizes */
 extern const struct kmalloc_info_struct {
 	const char *name[NR_KMALLOC_TYPES];
mm/slab_common.c +3 -1
index b7a46c368ab1..9fe48da12010 100644
@@ -29,6 +29,7 @@
 #include <linux/memcontrol.h>
 #include <linux/stackdepot.h>
 #include <trace/events/rcu.h>
+#include <kunit/visibility.h>
 
 #include "../kernel/rcu/rcu.h"
 #include "internal.h"
@@ -410,7 +411,8 @@ EXPORT_SYMBOL(__kmem_cache_create_args);
 
 static struct kmem_cache *kmem_buckets_cache __ro_after_init;
 
-static bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+VISIBLE_IF_KUNIT bool slab_buckets_enabled __ro_after_init = IS_ENABLED(CONFIG_SLAB_BUCKETS);
+EXPORT_SYMBOL_IF_KUNIT(slab_buckets_enabled);
 
 #ifdef CONFIG_SLAB_BUCKETS
 static int __init setup_slab_buckets(char *str)
Signature · 1 line
2.54.0
Signature · 1 line
Kees Cook
author
#13 lore raw

Re: [PATCH v2 4/6] slub_kunit: Add a test for the slab_buckets boot parameter

Hi Kees,

Quoted 2 lines · Kees Cook

Please don't ifdef to drop a test. If you have to do any ifdef, use it for test skipping instead.

Sure. In v3 the test is always built, and it calls kunit_skip() when CONFIG_SLAB_BUCKETS isn't set. The kmalloc_partition test in 6/6 gets the same treatment.

Quoted 2 lines

This feels messy. Any reason not to just export it entirely and avoid all the ifdefness?

No good reason. In v3 it's a normal global, declared in mm/slab.h without any #if. It's still only exported with EXPORT_SYMBOL_IF_KUNIT, since nothing other than the test needs it. kmalloc_partition_enabled gets the same change.

Thanks!

Chris

author
#14 lore raw

PATCH v2 5/6 mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot

In reply to Chris Down

KMALLOC_PARTITION_CACHES creates several copies of each normal kmalloc cache and spreads allocations across them. That costs a fair bit of
memory: Harry measured about 18 MiB more slab memory after boot on a 64 CPU, 64 GiB VM, mostly from under-used slabs [1]. Like SLAB_BUCKETS, it can only be chosen at build time.

Add a kmalloc_partition= early parameter, enabled by default on kernels built with CONFIG_KMALLOC_PARTITION_CACHES=y. When it's off, the copies alias the normal caches rather than being created.

Let's leave kmalloc_type() unchanged since each index simply resolves to the same cache when partitioning is off.

---
 .../admin-guide/kernel-parameters.txt         |  7 +++++++
 mm/Kconfig                                    |  5 +++++
 mm/slab_common.c                              | 19 ++++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index de2fd6963a16..6633a553a79c 100644
@@ -3054,6 +3054,13 @@ Kernel parameters
 			Configure the RouterBoard 532 series on-chip
 			Ethernet adapter MAC address.
 
+	kmalloc_partition= [MM,EARLY]
+			Format: <bool>
+			Enable or disable kmalloc cache partitioning on
+			kernels built with CONFIG_KMALLOC_PARTITION_CACHES=y.
+			Ignored without that option.
+			Default: on.
+
 	kmemleak=	[KNL,EARLY] Boot-time kmemleak enable/disable
 			Valid arguments: on, off
 			Default: on
mm/Kconfig +5 -0
index 48078c1fd26f..b90b3915fcd5 100644
@@ -266,6 +266,11 @@ config KMALLOC_PARTITION_CACHES
 	  limited degree of memory and CPU overhead that relates to hardware
 	  and system workload.
 
+	  The partitioning can be disabled at boot with the
+	  "kmalloc_partition=0" kernel parameter, in which case the copies
+	  are not created and all normal kmalloc allocations use the
+	  regular kmalloc caches.
+
 choice
 	prompt "Partitioned slab cache mode"
 	depends on KMALLOC_PARTITION_CACHES
mm/slab_common.c +18 -1
index 9fe48da12010..5391149a2eed 100644
@@ -781,6 +781,16 @@ unsigned long random_kmalloc_seed __ro_after_init;
 EXPORT_SYMBOL(random_kmalloc_seed);
 #endif
 
+#ifdef CONFIG_KMALLOC_PARTITION_CACHES
+static bool kmalloc_partition_enabled __ro_after_init = true;
+
+static int __init setup_kmalloc_partition(char *str)
+{
+	return kstrtobool(str, &kmalloc_partition_enabled);
+}
+early_param("kmalloc_partition", setup_kmalloc_partition);
+#endif
+
 /*
  * Conversion table for small slabs sizes / 8 to the index in the
  * kmalloc array. This is necessary for slabs < 192 since we have non power
@@ -1013,8 +1023,15 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type)
 	}
 
 #ifdef CONFIG_KMALLOC_PARTITION_CACHES
-	if (type >= KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END)
+	if (!kmalloc_partition_enabled) {
+		/* Use the normal caches, which have already been created. */
+		if (type > KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END) {
+			kmalloc_caches[type][idx] = kmalloc_caches[KMALLOC_NORMAL][idx];
+			return;
+		}
+	} else if (type >= KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END) {
 		flags |= SLAB_NO_MERGE;
+	}
 #endif
 
 	/*
Signature · 1 line
2.54.0
#15 lore raw

Re: [PATCH v2 5/6] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot

Quoted 77 lines · Chris Down

KMALLOC_PARTITION_CACHES creates several copies of each normal kmalloc cache and spreads allocations across them. That costs a fair bit of
memory: Harry measured about 18 MiB more slab memory after boot on a 64 CPU, 64 GiB VM, mostly from under-used slabs [1]. Like SLAB_BUCKETS, it can only be chosen at build time.

Add a kmalloc_partition= early parameter, enabled by default on kernels built with CONFIG_KMALLOC_PARTITION_CACHES=y. When it's off, the copies alias the normal caches rather than being created.

Let's leave kmalloc_type() unchanged since each index simply resolves to the same cache when partitioning is off.

---
 .../admin-guide/kernel-parameters.txt         |  7 +++++++
 mm/Kconfig                                    |  5 +++++
 mm/slab_common.c                              | 19 ++++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index de2fd6963a16..6633a553a79c 100644
@@ -3054,6 +3054,13 @@ Kernel parameters
 			Configure the RouterBoard 532 series on-chip
 			Ethernet adapter MAC address.
 
+	kmalloc_partition= [MM,EARLY]
+			Format: <bool>
+			Enable or disable kmalloc cache partitioning on
+			kernels built with CONFIG_KMALLOC_PARTITION_CACHES=y.
+			Ignored without that option.
+			Default: on.
+
 	kmemleak=	[KNL,EARLY] Boot-time kmemleak enable/disable
 			Valid arguments: on, off
 			Default: on
mm/Kconfig +5 -0
index 48078c1fd26f..b90b3915fcd5 100644
@@ -266,6 +266,11 @@ config KMALLOC_PARTITION_CACHES
 	  limited degree of memory and CPU overhead that relates to hardware
 	  and system workload.
 
+	  The partitioning can be disabled at boot with the
+	  "kmalloc_partition=0" kernel parameter, in which case the copies
+	  are not created and all normal kmalloc allocations use the
+	  regular kmalloc caches.
+
 choice
 	prompt "Partitioned slab cache mode"
 	depends on KMALLOC_PARTITION_CACHES
mm/slab_common.c +10 -0
index 9fe48da12010..5391149a2eed 100644
@@ -781,6 +781,16 @@ unsigned long random_kmalloc_seed __ro_after_init;
 EXPORT_SYMBOL(random_kmalloc_seed);
 #endif
 
+#ifdef CONFIG_KMALLOC_PARTITION_CACHES
+static bool kmalloc_partition_enabled __ro_after_init = true;
+
+static int __init setup_kmalloc_partition(char *str)
+{
+	return kstrtobool(str, &kmalloc_partition_enabled);
+}
+early_param("kmalloc_partition", setup_kmalloc_partition);
+#endif
+
 /*
  * Conversion table for small slabs sizes / 8 to the index in the
  * kmalloc array. This is necessary for slabs < 192 since we have non power

mm/slab_common.c new_kmalloc_cache(int idx, enum kmalloc_cache_type type) · line 1025

Quoted 3 lines
mm/slab_common.c +0 -0
@@ -1013,8 +1023,15 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type)
 	}
 
 #ifdef CONFIG_KMALLOC_PARTITION_CACHES

Swap the ifdef for a CONFIG-controlled static branch that defaults off without CONFIG_KMALLOC_PARTITION_CACHES.

Quoted 16 lines
mm/slab_common.c +8 -1
-	if (type >= KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END)
+	if (!kmalloc_partition_enabled) {
+		/* Use the normal caches, which have already been created. */
+		if (type > KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END) {
+			kmalloc_caches[type][idx] = kmalloc_caches[KMALLOC_NORMAL][idx];
+			return;
+		}
+	} else if (type >= KMALLOC_PARTITION_START && type <= KMALLOC_PARTITION_END) {
 		flags |= SLAB_NO_MERGE;
+	}
 #endif
 
 	/*
Signature · 1 line
2.54.0
Signature · 1 line
Kees Cook
author
#16 lore raw

Re: [PATCH v2 5/6] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot

Hi Kees,

Quoted 2 lines · Kees Cook

Swap the ifdef for a CONFIG-controlled static branch that defaults off without CONFIG_KMALLOC_PARTITION_CACHES.

I've dropped the #ifdef in v3. kmalloc_partition_enabled now defaults to IS_ENABLED(CONFIG_KMALLOC_PARTITION_CACHES), and kmalloc_partition= is ignored without that option, so new_kmalloc_cache() doesn't need any #ifdef.

I've kept it as a bool rather than a static key, for the same reason as on 3/6: the only reader is new_kmalloc_cache(), at boot. When partitioning is off, kmalloc_type() still picks a partition index, but every one of them resolves to the normal cache. So the flag is never read on the allocation path.

The one place a static key would actually help is kmalloc_type(), where it could skip picking a partition and go straight to KMALLOC_NORMAL. Since kmalloc_type() is inline, that means exporting the key to modules. That seemed like more than this series needs, but if you think it's worth it I'm happy to add it.

Thanks!

Chris

#17 lore raw

Re: [PATCH v2 5/6] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot

Quoted 15 lines · Chris Down
Quoted 2 lines · Kees Cook

Swap the ifdef for a CONFIG-controlled static branch that defaults off without CONFIG_KMALLOC_PARTITION_CACHES.

I've dropped the #ifdef in v3. kmalloc_partition_enabled now defaults to IS_ENABLED(CONFIG_KMALLOC_PARTITION_CACHES), and kmalloc_partition= is ignored without that option, so new_kmalloc_cache() doesn't need any #ifdef.

I've kept it as a bool rather than a static key, for the same reason as on 3/6: the only reader is new_kmalloc_cache(), at boot. When partitioning is off, kmalloc_type() still picks a partition index, but every one of them resolves to the normal cache. So the flag is never read on the allocation path.

Quoted 5 lines

The one place a static key would actually help is kmalloc_type(), where it could skip picking a partition and go straight to KMALLOC_NORMAL. Since kmalloc_type() is inline, that means exporting the key to modules. That seemed like more than this series needs, but if you think it's worth it I'm happy to add it.

I'll go look at v3. The goal was both immutability after init and avoiding a branch in an allocation path.

Signature · 1 line
Kees Cook
author
#18 lore raw

PATCH v2 6/6 slub_kunit: Add a test for the kmalloc_partition boot parameter

In reply to Chris Down

Check that the kmalloc partitions are separate caches by default, and alias the normal kmalloc caches when they're turned off with kmalloc_partition=0.

---
 lib/tests/slub_kunit.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 mm/slab.h              |  4 ++++
 mm/slab_common.c       |  3 ++-
 3 files changed, 52 insertions(+), 1 deletion(-)
lib/tests/slub_kunit.c +46 -0
index 670645875b27..e3035864577d 100644
@@ -333,6 +333,49 @@ static void test_slab_buckets(struct kunit *test)
 }
 #endif
 
+#ifdef CONFIG_KMALLOC_PARTITION_CACHES
+/*
+ * Each partition copy is a separate cache, unless the copies were disabled
+ * with kmalloc_partition=0: then they alias the KMALLOC_NORMAL caches.
+ */
+static void test_kmalloc_partition(struct kunit *test)
+{
+	enum kmalloc_cache_type type;
+	struct kmem_cache *s;
+	unsigned int idx;
+	bool found;
+	void *p;
+
+	for (type = KMALLOC_PARTITION_START + 1; type <= KMALLOC_PARTITION_END; type++) {
+		for (idx = 0; idx < ARRAY_SIZE(kmalloc_caches[type]); idx++) {
+			struct kmem_cache *normal = kmalloc_caches[KMALLOC_NORMAL][idx];
+			struct kmem_cache *part = kmalloc_caches[type][idx];
+
+			if (!kmalloc_partition_enabled) {
+				KUNIT_EXPECT_PTR_EQ(test, part, normal);
+			} else if (normal) {
+				KUNIT_EXPECT_NOT_NULL(test, part);
+				KUNIT_EXPECT_PTR_NE(test, part, normal);
+			}
+		}
+	}
+
+	p = kmalloc(64, GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, p);
+	s = virt_to_slab(p)->slab_cache;
+	idx = kmalloc_index(64);
+	if (!kmalloc_partition_enabled) {
+		KUNIT_EXPECT_PTR_EQ(test, s, kmalloc_caches[KMALLOC_NORMAL][idx]);
+	} else {
+		found = false;
+		for (type = KMALLOC_PARTITION_START; type <= KMALLOC_PARTITION_END; type++)
+			found |= s == kmalloc_caches[type][idx];
+		KUNIT_EXPECT_TRUE_MSG(test, found, "allocated from %s", s->name);
+	}
+	kfree(p);
+}
+#endif
+
 #if defined(CONFIG_PERF_EVENTS) || (defined(CONFIG_KPROBES) && defined(CONFIG_SMP))
 #define NR_ITERATIONS 1000
 #define NR_OBJECTS 1000
@@ -529,6 +572,9 @@ static struct kunit_case test_cases[] = {
 #ifdef CONFIG_SLAB_BUCKETS
 	KUNIT_CASE(test_slab_buckets),
 #endif
+#ifdef CONFIG_KMALLOC_PARTITION_CACHES
+	KUNIT_CASE(test_kmalloc_partition),
+#endif
 #ifdef CONFIG_PERF_EVENTS
 	KUNIT_CASE_SLOW(test_kmalloc_nolock_and_friends_perf),
 #endif
mm/slab.h +4 -0
index b5b344d6e402..8e1e5a3f044b 100644
@@ -394,6 +394,10 @@ extern struct kmem_cache *kmem_cache;
 extern bool slab_buckets_enabled;
 #endif
 
+#if IS_ENABLED(CONFIG_KUNIT) && defined(CONFIG_KMALLOC_PARTITION_CACHES)
+extern bool kmalloc_partition_enabled;
+#endif
+
 /* A table of kmalloc cache names and sizes */
 extern const struct kmalloc_info_struct {
 	const char *name[NR_KMALLOC_TYPES];
mm/slab_common.c +2 -1
index 5391149a2eed..406e8688ee0e 100644
@@ -782,7 +782,8 @@ EXPORT_SYMBOL(random_kmalloc_seed);
 #endif
 
 #ifdef CONFIG_KMALLOC_PARTITION_CACHES
-static bool kmalloc_partition_enabled __ro_after_init = true;
+VISIBLE_IF_KUNIT bool kmalloc_partition_enabled __ro_after_init = true;
+EXPORT_SYMBOL_IF_KUNIT(kmalloc_partition_enabled);
 
 static int __init setup_kmalloc_partition(char *str)
 {
Signature · 1 line
2.54.0
#19 lore raw

Re: [PATCH v2 6/6] slub_kunit: Add a test for the kmalloc_partition boot parameter

Quoted 16 lines · Chris Down

Check that the kmalloc partitions are separate caches by default, and alias the normal kmalloc caches when they're turned off with kmalloc_partition=0.

---
 lib/tests/slub_kunit.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 mm/slab.h              |  4 ++++
 mm/slab_common.c       |  3 ++-
 3 files changed, 52 insertions(+), 1 deletion(-)
lib/tests/slub_kunit.c +0 -0
index 670645875b27..e3035864577d 100644

lib/tests/slub_kunit.c static void test_slab_buckets(struct kunit *test) · line 336

Quoted 4 lines
lib/tests/slub_kunit.c +1 -0
@@ -333,6 +333,49 @@ static void test_slab_buckets(struct kunit *test)
 }
 #endif
 
+#ifdef CONFIG_KMALLOC_PARTITION_CACHES

Same feedback as the other test: let's get rid of all this ifdef-ery :)

Signature · 1 line
Kees Cook