[v4,2/3] exec: PR_HIDE_SELF_EXE hides /proc/self/map_files
Commit Message
extend the new prctl(PR_HIDE_SELF_EXE) to prevent using
/proc/self/map_files as well.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
---
fs/proc/base.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
@@ -2255,9 +2255,21 @@ proc_map_files_get_link(struct dentry *dentry,
struct inode *inode,
struct delayed_call *done)
{
+ struct task_struct *task;
+ bool hide_self_exe;
+
if (!checkpoint_restore_ns_capable(&init_user_ns))
return ERR_PTR(-EPERM);
+ task = get_proc_task(d_inode(dentry));
+ if (!task)
+ return ERR_PTR(-ENOENT);
+ hide_self_exe = is_hide_self_exe_blocked(task);
+ put_task_struct(task);
+
+ if (hide_self_exe)
+ return ERR_PTR(-EPERM);
+
return proc_pid_get_link(dentry, inode, done);
}