Skip to contentSkip to conversation

cred: prevent slab cache merging for cred_jar

PATCH Applied Mohammed EL Kadiri 2 participants 2 messages Jun 11 – Sep 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cred: prevent slab cache merging for cred_jar

Add SLAB_NO_MERGE to cred_jar to ensure struct cred objects get dedicated slab pages, preventing the allocator from merging this cache with other similarly-sized caches. This is a hardening measure to provide type isolation for credential objects.

---

Changes in v2:
- Collected Reviewed-by tag from Kees Cook.
- No code changes from v1.

 kernel/cred.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cred.c +1 -1
index 9676965c0981..0e4ee60a5acd 100644
@@ -557,7 +557,7 @@ void __init cred_init(void)
 {
 	/* allocate a slab in which we can store credentials */
 	cred_jar = KMEM_CACHE(cred,
-			      SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
+			      SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT | SLAB_NO_MERGE);
 }
 
 /**
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 8 lines · On Jun 11, 2026 Mohammed EL Kadiri <[email protected]> wrote:

Add SLAB_NO_MERGE to cred_jar to ensure struct cred objects get dedicated slab pages, preventing the allocator from merging this cache with other similarly-sized caches. This is a hardening measure to provide type isolation for credential objects.

Quoted 7 lines

---
Changes in v2:
- Collected Reviewed-by tag from Kees Cook.
- No code changes from v1.

 kernel/cred.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Merged into lsm/dev, thanks!

--
paul-moore.com