Messages in this thread Patch in this message | | | From | Djalal Harouni <> | Subject | [PATCH 3/9] proc: new proc_exec_id_ok() helper function | Date | Sun, 11 Mar 2012 00:25:13 +0100 |
| |
proc_exec_id_ok() will be used for /proc/<pid>/* files checks to see if the task's exec_id equals the exec_id of the proc_file_private struct.
Signed-off-by: Djalal Harouni <tixxdz@opendz.org> --- fs/proc/internal.h | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index a8968f6..bed27a8 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -10,6 +10,7 @@ */ #include <linux/proc_fs.h> +#include <linux/sched.h> extern struct proc_dir_entry proc_root; #ifdef CONFIG_PROC_SYSCTL @@ -95,6 +96,25 @@ static inline int proc_fd(struct inode *inode) return PROC_I(inode)->fd; } +/** + * proc_exec_id_ok - check if the task's exec_id equals the exec_id of + * the proc_file_private. + * @task: Task struct to check against. + * @proc_private: The proc_file_private struct. + * + * Check if the exec_id of the two structs are equal. Use it to protect + * special procfs files when the fd is passed to a new execve (i.e. suid) + * + * It will be more effective if the check is delayed as mush as possible + * to avoid any new execve surprises especially if we are checking against + * target task's exec_id. + */ +static inline int proc_exec_id_ok(struct task_struct *task, + struct proc_file_private *proc_priv) +{ + return task_exec_id_ok(task, proc_priv->exec_id); +} + struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *ino, struct dentry *dentry); int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, -- 1.7.1
| |