lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251129155500.43116-2-mjguzik@gmail.com>
Date: Sat, 29 Nov 2025 16:55:00 +0100
From: Mateusz Guzik <mjguzik@...il.com>
To: brauner@...nel.org
Cc: viro@...iv.linux.org.uk,
	jack@...e.cz,
	linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	Mateusz Guzik <mjguzik@...il.com>
Subject: [PATCH 2/2] fs: hide namei_cachep behind runtime const machinery

Signed-off-by: Mateusz Guzik <mjguzik@...il.com>
---
 fs/dcache.c                       |  7 ++++---
 include/asm-generic/vmlinux.lds.h |  4 +++-
 include/linux/namei.h             | 11 ++++++++++-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 23d1752c29e6..5cdcb3d0ee3b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3282,8 +3282,8 @@ static void __init dcache_init(void)
 }
 
 /* SLAB cache for __getname() consumers */
-struct kmem_cache *names_cachep __ro_after_init;
-EXPORT_SYMBOL(names_cachep);
+struct kmem_cache *__names_cachep __ro_after_init;
+EXPORT_SYMBOL(__names_cachep);
 
 void __init vfs_caches_init_early(void)
 {
@@ -3298,8 +3298,9 @@ void __init vfs_caches_init_early(void)
 
 void __init vfs_caches_init(void)
 {
-	names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0,
+	__names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0,
 			SLAB_HWCACHE_ALIGN|SLAB_PANIC, 0, PATH_MAX, NULL);
+	runtime_const_init(ptr, __names_cachep);
 
 	dcache_init();
 	inode_init();
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 8ca130af301f..890250fffbe0 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -972,7 +972,9 @@
 #define RUNTIME_CONST_VARIABLES						\
 		RUNTIME_CONST(shift, d_hash_shift)			\
 		RUNTIME_CONST(ptr, dentry_hashtable)			\
-		RUNTIME_CONST(ptr, __dentry_cache)
+		RUNTIME_CONST(ptr, __dentry_cache)			\
+		RUNTIME_CONST(ptr, __names_cachep)
+
 
 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
 #define KUNIT_TABLE()							\
diff --git a/include/linux/namei.h b/include/linux/namei.h
index bd4a7b058f97..c167f3a852e2 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -9,6 +9,10 @@
 #include <linux/errno.h>
 #include <linux/fs_struct.h>
 
+#ifndef MODULE
+#include <asm/runtime-const.h>
+#endif
+
 enum { MAX_NESTED_LINKS = 8 };
 
 #define MAXSYMLINKS 40
@@ -88,7 +92,12 @@ static inline struct filename *refname(struct filename *name)
 	return name;
 }
 
-extern struct kmem_cache *names_cachep;
+extern struct kmem_cache *__names_cachep;
+#ifdef MODULE
+#define names_cachep __names_cachep
+#else
+#define names_cachep runtime_const_ptr(__names_cachep)
+#endif
 
 #define __getname()		kmem_cache_alloc(names_cachep, GFP_KERNEL)
 #define __putname(name)		kmem_cache_free(names_cachep, (void *)(name))
-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ