History

proc: proc_pid_ns takes super_block as an argument

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.

Alexey Gladkov committed 6 years ago

Commit 9d78ede1 parent 2dd80839 files · +15 −15Browse files

Showing the changes to include/linux (1 of 9 files). Show all

Unified · Split

include/linux/proc_fs.h+2−2
@@ -202,9 +202,9 @@ int open_related_ns(struct ns_common *ns, · 201 unmodified lines
202202 struct ns_common *(*get_ns)(struct ns_common *ns));
203203
204204 /* 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)
206206 {
207− return proc_sb_info(inode->i_sb)->pid_ns;
207+ return proc_sb_info(sb)->pid_ns;
208208 }
209209
210210 #endif /* _LINUX_PROC_FS_H */