]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
kernfs: pass struct ns_common instead of const void * for namespace tags
authorChristian Brauner <brauner@kernel.org>
Wed, 1 Apr 2026 10:15:58 +0000 (12:15 +0200)
committerChristian Brauner <brauner@kernel.org>
Thu, 9 Apr 2026 12:36:52 +0000 (14:36 +0200)
commite3b2cf6e5dba416a03152f299d99982dfe1e861d
treed10833a41819fac2d0c066bd80def58a36453228
parent07712db80857d5d09ae08f3df85a708ecfc3b61f
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>
30 files changed:
drivers/base/class.c
drivers/base/core.c
drivers/infiniband/core/device.c
drivers/infiniband/ulp/srp/ib_srp.c
drivers/net/bonding/bond_sysfs.c
drivers/net/ipvlan/ipvtap.c
drivers/net/macvtap.c
fs/kernfs/dir.c
fs/kernfs/file.c
fs/kernfs/kernfs-internal.h
fs/kernfs/mount.c
fs/nfs/sysfs.c
fs/sysfs/dir.c
fs/sysfs/file.c
fs/sysfs/mount.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h
include/linux/device/class.h
include/linux/kernfs.h
include/linux/kobject.h
include/linux/kobject_ns.h
include/linux/netdevice.h
include/linux/sysfs.h
include/net/net_namespace.h
lib/kobject.c
lib/kobject_uevent.c
net/core/net-sysfs.c
net/core/net_namespace.c
net/sunrpc/sysfs.c
net/wireless/sysfs.c