syzbot found that touch /proc/testfile causes NULL pointer dereference at tomoyo_get_local_path() because inode of the dentry is NULL. Before c59f415a7cb6, Tomoyo received pid_ns from proc's s_fs_info directly. Since proc_pid_ns() can only work with inode, using it in the tomoyo_get_local_path() was wrong. To avoid creating more functions for getting proc_ns, change the argument type of the proc_pid_ns() function. Then, Tomoyo can use the existing super_block to get pid_ns.
Showing the changes to include/linux (1 of 9 files). Show all
Unified · Split
| @@ -202,9 +202,9 @@ int open_related_ns(struct ns_common *ns, · 201 unmodified lines | |||
| 202 | struct ns_common *(*get_ns)(struct ns_common *ns)); | 202 | struct ns_common *(*get_ns)(struct ns_common *ns)); |
| 203 | 203 | ||
| 204 | /* get the associated pid namespace for a file in procfs */ | 204 | /* get the associated pid namespace for a file in procfs */ |
| 205 | static inline struct pid_namespace *proc_pid_ns(const struct inode *inode) | 205 | static inline struct pid_namespace *proc_pid_ns(struct super_block *sb) |
| 206 | { | 206 | { |
| 207 | return proc_sb_info(inode->i_sb)->pid_ns; | 207 | return proc_sb_info(sb)->pid_ns; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | #endif /* _LINUX_PROC_FS_H */ | 210 | #endif /* _LINUX_PROC_FS_H */ |