aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authorAlexey Gladkov <[email protected]>2020-04-19 14:10:54 +0000
committerEric W. Biederman <[email protected]>2020-04-22 15:51:22 +0000
commit6814ef2d992af09451bbeda4770daa204461329e (patch)
treea0f3fad657964e61bc5c04e4add4e1255b33b7ed /fs/proc/generic.c
parentproc: instantiate only pids that we can ptrace on 'hidepid=4' mount option (diff)
downloadkernel-6814ef2d992af09451bbeda4770daa204461329e.tar.gz
kernel-6814ef2d992af09451bbeda4770daa204461329e.zip
proc: add option to mount only a pids subset
This allows to hide all files and directories in the procfs that are not related to tasks. Signed-off-by: Alexey Gladkov <[email protected]> Reviewed-by: Alexey Dobriyan <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 4ed6dabdf6ff..2f9fa179194d 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -269,6 +269,11 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
unsigned int flags)
{
+ struct proc_fs_info *fs_info = proc_sb_info(dir->i_sb);
+
+ if (fs_info->pidonly == PROC_PIDONLY_ON)
+ return ERR_PTR(-ENOENT);
+
return proc_lookup_de(dir, dentry, PDE(dir));
}
@@ -325,6 +330,10 @@ int proc_readdir_de(struct file *file, struct dir_context *ctx,
int proc_readdir(struct file *file, struct dir_context *ctx)
{
struct inode *inode = file_inode(file);
+ struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
+
+ if (fs_info->pidonly == PROC_PIDONLY_ON)
+ return 1;
return proc_readdir_de(file, ctx, PDE(inode));
}