summaryrefslogtreecommitdiff
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-04-01 13:15:58 +0300
committerChristian Brauner <brauner@kernel.org>2026-04-09 15:36:52 +0300
commite3b2cf6e5dba416a03152f299d99982dfe1e861d (patch)
treed10833a41819fac2d0c066bd80def58a36453228 /lib/kobject.c
parent07712db80857d5d09ae08f3df85a708ecfc3b61f (diff)
downloadlinux-e3b2cf6e5dba416a03152f299d99982dfe1e861d.tar.xz
kernfs: pass struct ns_common instead of const void * for namespace tags
kernfs has historically used const void * to pass around namespace tags used for directory-level namespace filtering. The only current user of this is sysfs network namespace tagging where struct net pointers are cast to void *. Replace all const void * namespace parameters with const struct ns_common * throughout the kernfs, sysfs, and kobject namespace layers. This includes the kobj_ns_type_operations callbacks, kobject_namespace(), and all sysfs/kernfs APIs that accept or return namespace tags. Passing struct ns_common is needed because various codepaths require access to the underlying namespace. A struct ns_common can always be converted back to the concrete namespace type (e.g., struct net) via container_of() or to_ns_common() in the reverse direction. This is a preparatory change for switching to ns_id-based directory iteration to prevent a KASLR pointer leak through the current use of raw namespace pointers as hash seeds and comparison keys. Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index cfdb2c3f20a2..9c9ff0f5175f 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -27,7 +27,7 @@
* and thus @kobj should have a namespace tag associated with it. Returns
* %NULL otherwise.
*/
-const void *kobject_namespace(const struct kobject *kobj)
+const struct ns_common *kobject_namespace(const struct kobject *kobj)
{
const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj);
@@ -1083,9 +1083,9 @@ bool kobj_ns_current_may_mount(enum kobj_ns_type type)
return may_mount;
}
-void *kobj_ns_grab_current(enum kobj_ns_type type)
+struct ns_common *kobj_ns_grab_current(enum kobj_ns_type type)
{
- void *ns = NULL;
+ struct ns_common *ns = NULL;
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type])
@@ -1096,7 +1096,7 @@ void *kobj_ns_grab_current(enum kobj_ns_type type)
}
EXPORT_SYMBOL_GPL(kobj_ns_grab_current);
-void kobj_ns_drop(enum kobj_ns_type type, void *ns)
+void kobj_ns_drop(enum kobj_ns_type type, struct ns_common *ns)
{
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) &&