linux-kernelorg-stable/fs
Fernando Fernandez Mancera c7fbb8218b sysfs: check visibility before changing group attribute ownership
Since commit 0c17270f9b ("net: sysfs: Implement is_visible for
phys_(port_id, port_name, switch_id)"), __dev_change_net_namespace() can
hit WARN_ON() when trying to change owner of a file that isn't visible.
See the trace below:

 WARNING: CPU: 6 PID: 2938 at net/core/dev.c:12410 __dev_change_net_namespace+0xb89/0xc30
 CPU: 6 UID: 0 PID: 2938 Comm: incusd Not tainted 6.17.1-1-mainline #1 PREEMPT(full)  4b783b4a638669fb644857f484487d17cb45ed1f
 Hardware name: Framework Laptop 13 (AMD Ryzen 7040Series)/FRANMDCP07, BIOS 03.07 02/19/2025
 RIP: 0010:__dev_change_net_namespace+0xb89/0xc30
 [...]
 Call Trace:
  <TASK>
  ? if6_seq_show+0x30/0x50
  do_setlink.isra.0+0xc7/0x1270
  ? __nla_validate_parse+0x5c/0xcc0
  ? security_capable+0x94/0x1a0
  rtnl_newlink+0x858/0xc20
  ? update_curr+0x8e/0x1c0
  ? update_entity_lag+0x71/0x80
  ? sched_balance_newidle+0x358/0x450
  ? psi_task_switch+0x113/0x2a0
  ? __pfx_rtnl_newlink+0x10/0x10
  rtnetlink_rcv_msg+0x346/0x3e0
  ? sched_clock+0x10/0x30
  ? __pfx_rtnetlink_rcv_msg+0x10/0x10
  netlink_rcv_skb+0x59/0x110
  netlink_unicast+0x285/0x3c0
  ? __alloc_skb+0xdb/0x1a0
  netlink_sendmsg+0x20d/0x430
  ____sys_sendmsg+0x39f/0x3d0
  ? import_iovec+0x2f/0x40
  ___sys_sendmsg+0x99/0xe0
  __sys_sendmsg+0x8a/0xf0
  do_syscall_64+0x81/0x970
  ? __sys_bind+0xe3/0x110
  ? syscall_exit_work+0x143/0x1b0
  ? do_syscall_64+0x244/0x970
  ? sock_alloc_file+0x63/0xc0
  ? syscall_exit_work+0x143/0x1b0
  ? do_syscall_64+0x244/0x970
  ? alloc_fd+0x12e/0x190
  ? put_unused_fd+0x2a/0x70
  ? do_sys_openat2+0xa2/0xe0
  ? syscall_exit_work+0x143/0x1b0
  ? do_syscall_64+0x244/0x970
  ? exc_page_fault+0x7e/0x1a0
  entry_SYSCALL_64_after_hwframe+0x76/0x7e
 [...]
  </TASK>

Fix this by checking is_visible() before trying to touch the attribute.

Fixes: 303a42769c ("sysfs: add sysfs_group{s}_change_owner()")
Fixes: 0c17270f9b ("net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)")
Reported-by: Cynthia <cynthia@kosmx.dev>
Closes: https://lore.kernel.org/netdev/01070199e22de7f8-28f711ab-d3f1-46d9-b9a0-048ab05eb09b-000000@eu-central-1.amazonses.com/
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20251016101456.4087-1-fmancera@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-10-17 09:48:34 +02:00
..
9p Bunch of unrelated fixes 2025-10-09 11:56:59 -07:00
adfs
affs
afs Simplifying ->d_name audits, easy part. 2025-10-03 11:14:02 -07:00
autofs
befs
bfs
btrfs for-6.18-tag 2025-10-06 13:53:19 -07:00
cachefiles VFS: unify old_mnt_idmap and new_mnt_idmap in renamedata 2025-09-23 12:37:35 +02:00
ceph Some messenger improvements from Eric and Max, a patch to address the 2025-10-10 11:30:19 -07:00
coda
configfs file->f_path constification 2025-10-03 16:32:36 -07:00
cramfs Patch series in this pull request: 2025-10-02 18:44:54 -07:00
crypto fscrypt updates for 6.18 2025-09-29 15:33:50 -07:00
debugfs vfs-6.18-rc1.async 2025-09-29 11:55:15 -07:00
devpts
dlm dlm for 6.18 2025-09-29 15:24:58 -07:00
ecryptfs mount-related stuff for this cycle 2025-10-03 10:19:44 -07:00
efivarfs vfs-6.18-rc1.misc 2025-09-29 09:03:07 -07:00
efs
erofs erofs: drop redundant sanity check for ztailpacking inline 2025-09-25 11:26:39 +08:00
exfat Description for this pull request: 2025-10-03 14:02:53 -07:00
exportfs
ext2
ext4 New ext4 features: 2025-10-03 13:47:10 -07:00
f2fs f2fs-for-6.18-rc1 2025-10-03 14:05:12 -07:00
fat vfat: remove unused variable 2025-09-13 17:32:47 -07:00
freevxfs
fuse fuse update for 6.18 2025-10-03 12:48:18 -07:00
gfs2 finish_no_open calling conventions change 2025-10-03 10:59:31 -07:00
hfs hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
hfsplus hfs/hfsplus: rework debug output subsystem 2025-09-24 16:30:34 -07:00
hostfs fs: rename generic_delete_inode() and generic_drop_inode() 2025-09-15 16:09:42 +02:00
hpfs - Avoid -Wflex-array-member-not-at-end warnings 2025-10-10 14:06:02 -07:00
hugetlbfs Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
iomap iomap: open code bio_iov_iter_get_bdev_pages 2025-10-07 08:05:44 -06:00
isofs
jbd2 jbd2: increase IO priority of checkpoint 2025-09-25 14:37:07 -04:00
jffs2 mm: introduce memdesc_flags_t 2025-09-13 16:55:07 -07:00
jfs A few fixes and cleanups for JFS. 2025-10-03 13:54:23 -07:00
kernfs vfs-6.18-rc1.misc 2025-09-29 09:03:07 -07:00
lockd SUNRPC: Move the svc_rpcb_cleanup() call sites 2025-09-23 13:28:19 -04:00
minix
netfs vfs-6.18-rc1.workqueue 2025-09-29 10:27:17 -07:00
nfs file->f_path constification 2025-10-03 16:32:36 -07:00
nfs_common
nfsd NFSD 6.18 Release Notes 2025-10-06 13:22:21 -07:00
nilfs2 Merge branch 'mm-hotfixes-stable' into mm-stable in order to pick up 2025-09-21 14:19:36 -07:00
nls
notify \n 2025-10-03 13:23:10 -07:00
ntfs3 ntfs3: stop using write_cache_pages 2025-09-13 16:55:13 -07:00
ocfs2 Patch series in this pull request: 2025-10-02 18:44:54 -07:00
omfs
openpromfs
orangefs orangefs: Two cleanups and a bug fix. 2025-10-03 13:59:56 -07:00
overlayfs file->f_path constification 2025-10-03 16:32:36 -07:00
proc Patch series in this pull request: 2025-10-02 18:44:54 -07:00
pstore pstore update for v6.18-rc1 2025-09-29 18:08:34 -07:00
qnx4
qnx6
quota fs: replace use of system_unbound_wq with system_dfl_wq 2025-09-19 16:15:07 +02:00
ramfs fs: rename generic_delete_inode() and generic_drop_inode() 2025-09-15 16:09:42 +02:00
resctrl fs/resctrl: Fix counter auto-assignment on mkdir with mbm_event enabled 2025-09-17 11:31:12 +02:00
romfs
smb 20 smb client fixes 2025-10-10 11:23:57 -07:00
squashfs Patch series in this pull request: 2025-10-02 18:44:54 -07:00
sysfs sysfs: check visibility before changing group attribute ownership 2025-10-17 09:48:34 +02:00
tests
tracefs
ubifs Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
udf fs: udf: fix OOB read in lengthAllocDescs handling 2025-09-22 15:33:56 +02:00
ufs
unicode
vboxsf simplify vboxsf_dir_atomic_open() 2025-09-16 23:59:38 -04:00
verity Optimize fsverity with 2-way interleaved hashing 2025-09-29 15:55:20 -07:00
xfs xfs: new code for 6.18 2025-09-29 14:35:44 -07:00
zonefs
Kconfig Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
Kconfig.binfmt binfmt_elf: preserve original ELF e_flags for core dumps 2025-09-03 20:49:32 -07:00
Makefile Remove bcachefs core code 2025-09-29 13:43:52 -07:00
aio.c Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
anon_inodes.c
attr.c vfs: add ATTR_CTIME_SET flag 2025-09-21 19:24:50 -04:00
backing-file.c
bad_inode.c
binfmt_elf.c binfmt_elf: preserve original ELF e_flags for core dumps 2025-09-03 20:49:32 -07:00
binfmt_elf_fdpic.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
bpf_fs_kfuncs.c bpf...d_path(): constify path argument 2025-09-15 21:17:08 -04:00
buffer.c
char_dev.c
compat_binfmt_elf.c
coredump.c Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
d_path.c
dax.c fs/dax: use vmf_insert_folio_pmd() to insert the huge zero folio 2025-09-13 16:54:51 -07:00
dcache.c Simplifying ->d_name audits, easy part. 2025-10-03 11:14:02 -07:00
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c eventpoll: Replace rwlock with spinlock 2025-09-05 15:51:24 +02:00
exec.c Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
fcntl.c fcntl: trim arguments 2025-09-26 10:21:23 +02:00
fhandle.c namespace-6.18-rc1 2025-09-29 11:20:29 -07:00
file.c
file_attr.c
file_table.c Have cc(1) catch attempts to modify ->f_path 2025-09-27 20:18:41 -04:00
filesystems.c
fs-writeback.c vfs-6.18-rc1.writeback 2025-09-29 11:34:40 -07:00
fs_context.c change the calling conventions for vfs_parse_fs_string() 2025-09-04 15:20:51 -04:00
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c VFS: rename kern_path_locked() and related functions. 2025-09-23 12:37:36 +02:00
inode.c vfs-6.18-rc1.inode 2025-09-29 09:42:30 -07:00
internal.h file->f_path constification 2025-10-03 16:32:36 -07:00
ioctl.c fs: remove vfs_ioctl export 2025-09-01 13:08:01 +02:00
kernel_read_file.c
libfs.c
locks.c
mbcache.c
mnt_idmapping.c
mount.h mount-related stuff for this cycle 2025-10-03 10:19:44 -07:00
mpage.c mpage: convert do_mpage_readpage() to return void type 2025-09-21 14:22:16 -07:00
namei.c file->f_path constification 2025-10-03 16:32:36 -07:00
namespace.c vfs_parse_fs_string() stuff 2025-10-03 10:51:44 -07:00
nsfs.c file->f_path constification 2025-10-03 16:32:36 -07:00
open.c file->f_path constification 2025-10-03 16:32:36 -07:00
pidfs.c file->f_path constification 2025-10-03 16:32:36 -07:00
pipe.c Add RWF_NOSIGNAL flag for pwritev2 2025-08-29 15:08:07 +02:00
pnode.c umount_tree(): take all victims out of propagation graph at once 2025-09-15 21:26:44 -04:00
pnode.h umount_tree(): take all victims out of propagation graph at once 2025-09-15 21:26:44 -04:00
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c constify path argument of vfs_statx_path() 2025-09-15 21:17:07 -04:00
statfs.c
super.c mount-related stuff for this cycle 2025-10-03 10:19:44 -07:00
sync.c
sysctls.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c