aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangzijie <[email protected]>2025-09-04 13:57:15 +0000
committerAndrew Morton <[email protected]>2025-09-09 06:45:12 +0000
commit0ce9398aa0830f15f92bbed73853f9861c3e74ff (patch)
treeb5bdfd6c266b023108481ba8887ced2aeaf5f46f
parentcompiler-clang.h: define __SANITIZE_*__ macros only when undefined (diff)
downloadkernel-0ce9398aa0830f15f92bbed73853f9861c3e74ff.tar.gz
kernel-0ce9398aa0830f15f92bbed73853f9861c3e74ff.zip
proc: fix type confusion in pde_set_flags()
Commit 2ce3d282bd50 ("proc: fix missing pde_set_flags() for net proc files") missed a key part in the definition of proc_dir_entry: union { const struct proc_ops *proc_ops; const struct file_operations *proc_dir_ops; }; So dereference of ->proc_ops assumes it is a proc_ops structure results in type confusion and make NULL check for 'proc_ops' not work for proc dir. Add !S_ISDIR(dp->mode) test before calling pde_set_flags() to fix it. Link: https://lkml.kernel.org/r/[email protected] Fixes: 2ce3d282bd50 ("proc: fix missing pde_set_flags() for net proc files") Signed-off-by: wangzijie <[email protected]> Reported-by: Brad Spengler <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Cc: Alexey Dobriyan <[email protected]> Cc: Al Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Stefano Brivio <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--fs/proc/generic.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bd0c099cfdd2..176281112273 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -393,7 +393,8 @@ struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
if (proc_alloc_inum(&dp->low_ino))
goto out_free_entry;
- pde_set_flags(dp);
+ if (!S_ISDIR(dp->mode))
+ pde_set_flags(dp);
write_lock(&proc_subdir_lock);
dp->parent = dir;