Files
linux/fs/proc
wangzijie 2ce3d282bd proc: fix missing pde_set_flags() for net proc files
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().

[[email protected]: stash pde->proc_ops in a local const variable, per Christian]
  Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/all/[email protected]/ [1]
Fixes: ff7ec8dc1b ("proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al")
Signed-off-by: wangzijie <[email protected]>
Reported-by: Lars Wendler <[email protected]>
Tested-by: Stefano Brivio <[email protected]>
Tested-by: Petr Vaněk <[email protected]>
Tested by: Lars Wendler <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Al Viro <[email protected]>
Cc: "Edgecombe, Rick P" <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: wangzijie <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-08-27 22:45:44 -07:00
..
…
…
…
…
2025-02-10 16:56:58 -08:00
…
…
…
…
2025-07-10 09:39:18 +02:00
…
…
…
…
…