From: Giuseppe Scrivano <gscrivan@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: keescook@chromium.org, bristot@redhat.com, ebiederm@xmission.com,
brauner@kernel.org, cyphar@cyphar.com, viro@zeniv.linux.org.uk,
walters@verbum.org, avagin@gmail.com, alexl@redhat.com,
peterz@infradead.org, bmasney@redhat.com, gscrivan@redhat.com
Subject: [PATCH v4 2/3] exec: PR_HIDE_SELF_EXE hides /proc/self/map_files
Date: Fri, 10 Mar 2023 12:25:53 +0100 [thread overview]
Message-ID: <20230310112554.1261731-2-gscrivan@redhat.com> (raw)
In-Reply-To: <20230310112554.1261731-1-gscrivan@redhat.com>
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(+)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 14102a133655..72f1cb44691f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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);
}
--
2.39.2
next prev parent reply other threads:[~2023-03-10 11:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 11:25 [PATCH v4 1/3] exec: add PR_HIDE_SELF_EXE prctl Giuseppe Scrivano
2023-03-10 11:25 ` Giuseppe Scrivano [this message]
2023-03-10 11:25 ` [PATCH v4 3/3] selftests: add tests for prctl(SET_HIDE_SELF_EXE) Giuseppe Scrivano
2023-03-14 9:44 ` [PATCH v4 1/3] exec: add PR_HIDE_SELF_EXE prctl Giuseppe Scrivano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230310112554.1261731-2-gscrivan@redhat.com \
--to=gscrivan@redhat.com \
--cc=alexl@redhat.com \
--cc=avagin@gmail.com \
--cc=bmasney@redhat.com \
--cc=brauner@kernel.org \
--cc=bristot@redhat.com \
--cc=cyphar@cyphar.com \
--cc=ebiederm@xmission.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=viro@zeniv.linux.org.uk \
--cc=walters@verbum.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®