summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-04-10 08:40:49 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-04-10 08:40:49 -0700
commit7c6c4ed80b874f721bc7c2c937e098c56e37d2f0 (patch)
tree6e388c10e8f3a4edf98bdf04c0ae7b8fdb81c5cd /net
parent96463e4e0268dddbdb60fd1b96800736aa2bade9 (diff)
parentcb76a81c7cec37bdf525164561b02665cd763421 (diff)
Merge tag 'vfs-7.0-rc8.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: "The kernfs rbtree is keyed by (hash, ns, name) where the hash is seeded with the raw namespace pointer via init_name_hash(ns). The resulting hash values are exposed to userspace through readdir seek positions, and the pointer-based ordering in kernfs_name_compare() is observable through entry order. Switch from raw pointers to ns_common::ns_id for both hashing and comparison. A preparatory commit first replaces all const void * namespace parameters with const struct ns_common * throughout kernfs, sysfs, and kobject so the code can access ns->ns_id. Also compare the ns_id when hashes match in the rbtree to handle crafted collisions. Also fix eventpoll RCU grace period issue and a cachefiles refcount problem" * tag 'vfs-7.0-rc8.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: kernfs: make directory seek namespace-aware kernfs: use namespace id instead of pointer for hashing and comparison kernfs: pass struct ns_common instead of const void * for namespace tags eventpoll: defer struct eventpoll free to RCU grace period cachefiles: fix incorrect dentry refcount in cachefiles_cull()
Diffstat (limited to 'net')
-rw-r--r--net/core/net-sysfs.c50
-rw-r--r--net/core/net_namespace.c8
-rw-r--r--net/sunrpc/sysfs.c17
-rw-r--r--net/wireless/sysfs.c4
4 files changed, 40 insertions, 39 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 07624b682b08..b9740a397f55 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1181,24 +1181,24 @@ static void rx_queue_release(struct kobject *kobj)
netdev_put(queue->dev, &queue->dev_tracker);
}
-static const void *rx_queue_namespace(const struct kobject *kobj)
+static const struct ns_common *rx_queue_namespace(const struct kobject *kobj)
{
struct netdev_rx_queue *queue = to_rx_queue(kobj);
struct device *dev = &queue->dev->dev;
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void rx_queue_get_ownership(const struct kobject *kobj,
kuid_t *uid, kgid_t *gid)
{
- const struct net *net = rx_queue_namespace(kobj);
+ const struct ns_common *ns = rx_queue_namespace(kobj);
- net_ns_get_ownership(net, uid, gid);
+ net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
+ uid, gid);
}
static const struct kobj_type rx_queue_ktype = {
@@ -1931,24 +1931,24 @@ static void netdev_queue_release(struct kobject *kobj)
netdev_put(queue->dev, &queue->dev_tracker);
}
-static const void *netdev_queue_namespace(const struct kobject *kobj)
+static const struct ns_common *netdev_queue_namespace(const struct kobject *kobj)
{
struct netdev_queue *queue = to_netdev_queue(kobj);
struct device *dev = &queue->dev->dev;
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void netdev_queue_get_ownership(const struct kobject *kobj,
kuid_t *uid, kgid_t *gid)
{
- const struct net *net = netdev_queue_namespace(kobj);
+ const struct ns_common *ns = netdev_queue_namespace(kobj);
- net_ns_get_ownership(net, uid, gid);
+ net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
+ uid, gid);
}
static const struct kobj_type netdev_queue_ktype = {
@@ -2185,24 +2185,24 @@ static bool net_current_may_mount(void)
return ns_capable(net->user_ns, CAP_SYS_ADMIN);
}
-static void *net_grab_current_ns(void)
+static struct ns_common *net_grab_current_ns(void)
{
- struct net *ns = current->nsproxy->net_ns;
+ struct net *net = current->nsproxy->net_ns;
#ifdef CONFIG_NET_NS
- if (ns)
- refcount_inc(&ns->passive);
+ if (net)
+ refcount_inc(&net->passive);
#endif
- return ns;
+ return net ? to_ns_common(net) : NULL;
}
-static const void *net_initial_ns(void)
+static const struct ns_common *net_initial_ns(void)
{
- return &init_net;
+ return to_ns_common(&init_net);
}
-static const void *net_netlink_ns(struct sock *sk)
+static const struct ns_common *net_netlink_ns(struct sock *sk)
{
- return sock_net(sk);
+ return to_ns_common(sock_net(sk));
}
const struct kobj_ns_type_operations net_ns_type_operations = {
@@ -2252,11 +2252,11 @@ static void netdev_release(struct device *d)
kvfree(dev);
}
-static const void *net_namespace(const struct device *d)
+static const struct ns_common *net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d);
- return dev_net(dev);
+ return to_ns_common(dev_net(dev));
}
static void net_get_ownership(const struct device *d, kuid_t *uid, kgid_t *gid)
@@ -2402,14 +2402,14 @@ int netdev_change_owner(struct net_device *ndev, const struct net *net_old,
}
int netdev_class_create_file_ns(const struct class_attribute *class_attr,
- const void *ns)
+ const struct ns_common *ns)
{
return class_create_file_ns(&net_class, class_attr, ns);
}
EXPORT_SYMBOL(netdev_class_create_file_ns);
void netdev_class_remove_file_ns(const struct class_attribute *class_attr,
- const void *ns)
+ const struct ns_common *ns)
{
class_remove_file_ns(&net_class, class_attr, ns);
}
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1057d16d5dd2..24aa10a1d0ea 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -540,12 +540,10 @@ void net_passive_dec(struct net *net)
}
}
-void net_drop_ns(void *p)
+void net_drop_ns(struct ns_common *ns)
{
- struct net *net = (struct net *)p;
-
- if (net)
- net_passive_dec(net);
+ if (ns)
+ net_passive_dec(to_net_ns(ns));
}
struct net *copy_net_ns(u64 flags,
diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
index af8fac9cedd4..a90480f80154 100644
--- a/net/sunrpc/sysfs.c
+++ b/net/sunrpc/sysfs.c
@@ -6,6 +6,7 @@
#include <linux/kobject.h>
#include <linux/sunrpc/addr.h>
#include <linux/sunrpc/xprtsock.h>
+#include <net/net_namespace.h>
#include "sysfs.h"
@@ -553,20 +554,22 @@ static void rpc_sysfs_xprt_release(struct kobject *kobj)
kfree(xprt);
}
-static const void *rpc_sysfs_client_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_client_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_client, kobject)->net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_client,
+ kobject)->net);
}
-static const void *rpc_sysfs_xprt_switch_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_xprt_switch_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_xprt_switch, kobject)->net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt_switch,
+ kobject)->net);
}
-static const void *rpc_sysfs_xprt_namespace(const struct kobject *kobj)
+static const struct ns_common *rpc_sysfs_xprt_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct rpc_sysfs_xprt,
- kobject)->xprt->xprt_net;
+ return to_ns_common(container_of(kobj, struct rpc_sysfs_xprt,
+ kobject)->xprt->xprt_net);
}
static struct kobj_attribute rpc_sysfs_clnt_version = __ATTR(rpc_version,
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 2e0ea69b9604..0b9abe70d39d 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -154,11 +154,11 @@ static SIMPLE_DEV_PM_OPS(wiphy_pm_ops, wiphy_suspend, wiphy_resume);
#define WIPHY_PM_OPS NULL
#endif
-static const void *wiphy_namespace(const struct device *d)
+static const struct ns_common *wiphy_namespace(const struct device *d)
{
struct wiphy *wiphy = container_of(d, struct wiphy, dev);
- return wiphy_net(wiphy);
+ return to_ns_common(wiphy_net(wiphy));
}
struct class ieee80211_class = {