]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
keys: prevent slab cache merging for key_jar
authorMohammed EL Kadiri <med08elkadiri@gmail.com>
Wed, 10 Jun 2026 06:50:52 +0000 (07:50 +0100)
committerJarkko Sakkinen <jarkko@kernel.org>
Mon, 15 Jun 2026 12:19:13 +0000 (15:19 +0300)
Add SLAB_NO_MERGE to key_jar to prevent the allocator from merging it
with other similarly-sized caches. This hardens struct key isolation by
ensuring dedicated slab pages.

Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20260610065052.9120-1-med08elkadiri@gmail.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
security/keys/key.c

index 091ee084bc3006e4f6b7fab40644ef996382ca49..b34a64d81d47ab7fc95cb271b3f5249b65ac4d1e 100644 (file)
@@ -1275,7 +1275,7 @@ void __init key_init(void)
 {
        /* allocate a slab in which we can store keys */
        key_jar = kmem_cache_create("key_jar", sizeof(struct key),
-                       0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
+                       0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_NO_MERGE, NULL);
 
        /* add the special key types */
        list_add_tail(&key_type_keyring.link, &key_types_list);