linux-yocto/fs/proc
wangzijie 0b0d6ad8a7 proc: fix missing pde_set_flags() for net proc files
commit 2ce3d282bd5050fca8577defeff08ada0d55d062 upstream.

To avoid potential UAF issues during module removal races, we use
pde_set_flags() to save proc_ops flags in PDE itself before
proc_register(), and then use pde_has_proc_*() helpers instead of directly
dereferencing pde->proc_ops->*.

However, the pde_set_flags() call was missing when creating net related
proc files.  This omission caused incorrect behavior which FMODE_LSEEK was
being cleared inappropriately in proc_reg_open() for net proc files.  Lars
reported it in this link[1].

Fix this by ensuring pde_set_flags() is called when register proc entry,
and add NULL check for proc_ops in pde_set_flags().

[wangzijie1@honor.com: stash pde->proc_ops in a local const variable, per Christian]
  Link: https://lkml.kernel.org/r/20250821105806.1453833-1-wangzijie1@honor.com
Link: https://lkml.kernel.org/r/20250818123102.959595-1-wangzijie1@honor.com
Link: https://lore.kernel.org/all/20250815195616.64497967@chagall.paradoxon.rec/ [1]
Fixes: ff7ec8dc1b ("proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al")
Signed-off-by: wangzijie <wangzijie1@honor.com>
Reported-by: Lars Wendler <polynomial-c@gmx.de>
Tested-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Petr Vaněk <pv@excello.cz>
Tested by: Lars Wendler <polynomial-c@gmx.de>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Kirill A. Shutemov <k.shutemov@gmail.com>
Cc: wangzijie <wangzijie1@honor.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-09-09 18:54:17 +02:00
..
array.c fs/proc: do_task_stat: Fix ESP not readable during coredump 2025-02-21 13:49:39 +01:00
base.c fs/procfs: fix the comment above proc_pid_wchan() 2025-04-10 14:33:37 +02:00
bootconfig.c
cmdline.c
consoles.c
cpuinfo.c
devices.c
fd.c
fd.h
generic.c proc: fix missing pde_set_flags() for net proc files 2025-09-09 18:54:17 +02:00
inode.c proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al 2025-08-15 12:05:03 +02:00
internal.h proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al 2025-08-15 12:05:03 +02:00
interrupts.c
Kconfig
kcore.c fs/proc/kcore.c: Clear ret value in read_kcore_iter after successful iov_iter_zero 2024-12-14 19:54:15 +01:00
kmsg.c
loadavg.c
Makefile
meminfo.c
namespaces.c
nommu.c
page.c
proc_net.c
proc_sysctl.c fix proc_sys_compare() handling of in-lookup dentries 2025-07-17 18:32:05 +02:00
proc_tty.c
root.c
self.c
softirqs.c proc/softirqs: replace seq_printf with seq_put_decimal_ull_width 2024-12-14 19:53:10 +01:00
stat.c
task_mmu.c
task_nommu.c
thread_self.c
uptime.c
util.c
version.c
vmcore.c fs/proc: fix softlockup in __read_vmcore (part 2) 2025-01-23 17:17:14 +01:00