[Devel] [PATCH RHEL10 COMMIT] kernfs: build the KERNFS_GET_NS ioctl only with CONFIG_NET
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 21 19:42:25 MSK 2026
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.6.vz10
------>
commit 370fbd80ffc815f87e01ec8f2184141367a37e08
Author: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Date: Fri Aug 21 18:37:11 2026 +0200
kernfs: build the KERNFS_GET_NS ioctl only with CONFIG_NET
The KERNFS_GET_NS ioctl hands out the network namespace a sysfs directory
is tagged with, so it calls maybe_get_net_ns(), which exists only with the
networking stack:
fs/kernfs/file.c:1030:50: error: 'maybe_get_net_ns' undeclared (first
use in this function)
fs/kernfs/file.c:1029:21: error: this statement may fall through
[-Werror=implicit-fallthrough=]
Compile the whole body under CONFIG_NET and return -ENOTTY otherwise. The
three local variables move inside the guard along with it: left at function
scope they are unused with CONFIG_NET=n, which is an error once
CONFIG_WERROR=y.
The switch is replaced by an if as part of that, because it reads better
once there is an #ifdef in the picture. Keeping the switch would mean
either a second #ifdef of its own around the declarations, or a switch
whose only unconditional arm is the default one; an if plus a tail return
says the same thing under a single guard.
Fixes: 38c2983fa828 ("kernfs/sysfs: add ioctl to get fd network namespace tag")
Feature: sysfs: per-CT entries visibility and permissions configuration
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/kernfs/file.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 092a4dcd2ebfb..5c72f05a9e41f 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -1018,19 +1018,19 @@ EXPORT_SYMBOL_GPL(kernfs_notify);
long kernfs_ioctl(struct file *file, unsigned int ioctl,
unsigned long arg)
{
+#ifdef CONFIG_NET
struct dentry *dentry = file->f_path.dentry;
const void *ns = kernfs_info(dentry->d_sb)->ns;
struct net *net;
- switch (ioctl) {
- case KERNFS_GET_NS:
+ if (ioctl == KERNFS_GET_NS) {
if (dentry->d_sb->s_magic != SYSFS_MAGIC || !ns)
return -ENOTTY;
net = (struct net *)ns;
return open_related_ns(&net->ns, maybe_get_net_ns);
- default:
- return -ENOTTY;
}
+#endif
+ return -ENOTTY;
}
const struct file_operations kernfs_file_fops = {
More information about the Devel
mailing list