On Mon, Aug 18, 2025 at 07:24:28PM +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) > Reported-by: Lars Wendler <polynomial-c@xxxxxx> > Signed-off-by: wangzijie <wangzijie1@xxxxxxxxx> > --- > v2: > - followed by Jiri's suggestion to refractor code and reformat commit message > --- > fs/proc/generic.c | 36 +++++++++++++++++++----------------- > 1 file changed, 19 insertions(+), 17 deletions(-) > <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter>