From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I6WKXZ CVE: NA
--------------------------------
Introduce proc_hide_ents to hide proc files.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- fs/proc/base.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c index 243c15919e18..96313167702d 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2657,6 +2657,11 @@ static struct dentry *proc_pident_instantiate(struct dentry *dentry, return d_splice_alias(inode, dentry); }
+static bool proc_hide_pidents(const struct pid_entry *p) +{ + return false; +} + static struct dentry *proc_pident_lookup(struct inode *dir, struct dentry *dentry, const struct pid_entry *p, @@ -2675,6 +2680,8 @@ static struct dentry *proc_pident_lookup(struct inode *dir, for (; p < end; p++) { if (p->len != dentry->d_name.len) continue; + if (proc_hide_pidents(p)) + continue; if (!memcmp(dentry->d_name.name, p->name, p->len)) { res = proc_pident_instantiate(dentry, task, p); break; @@ -2701,8 +2708,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx, goto out;
for (p = ents + (ctx->pos - 2); p < ents + nents; p++) { - if (!proc_fill_cache(file, ctx, p->name, p->len, - proc_pident_instantiate, task, p)) + if (!proc_hide_pidents(p) && + !proc_fill_cache(file, ctx, p->name, p->len, + proc_pident_instantiate, task, p)) break; ctx->pos++; }