On Thu, Aug 21, 2025 at 06:58:06PM +0800, wangzijie wrote: > 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(). > > [1]: https://lore.kernel.org/all/20250815195616.64497967@xxxxxxxxxxxxxxxxxxxxx/ > > Fixes: ff7ec8dc1b64 ("proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al") > Cc: stable@xxxxxxxxxxxxxxx > Reported-by: Lars Wendler <polynomial-c@xxxxxx> > Signed-off-by: wangzijie <wangzijie1@xxxxxxxxx> Tested-by: Petr Vaněk <pv@xxxxxxxxxx> We have noticed lseek issue with /proc/self/net/sockstat file recently and this patch fixes it for us. Thanks, Petr