From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Fri, 21 Aug 2026 18:42:25 +0200 Subject: [Devel] [PATCH RHEL10 COMMIT] kernfs: build the KERNFS_GET_NS ioctl only with CONFIG_NET In-Reply-To: <20260821163718.187766-26-khorenko@virtuozzo.com> Message-ID: <202608211642.67LGgPqk668189@f0.sw.ru> List-Id: 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 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 Signed-off-by: Konstantin Khorenko --- 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 = {