From: "Adrian Ratiu" <adrian.ratiu@collabora.com>
To: "Christian Brauner" <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
linux-doc@vger.kernel.org, kernel@collabora.com, gbiv@google.com,
ryanbeltran@google.com, inglorion@google.com,
ajordanr@google.com, jorgelo@chromium.org,
"Jann Horn" <jannh@google.com>,
"Kees Cook" <keescook@chromium.org>,
"Jeff Xu" <jeffxu@google.com>, "Kees Cook" <kees@kernel.org>
Subject: Re: [PATCH v6 1/2] proc: pass file instead of inode to proc_mem_open
Date: Mon, 17 Jun 2024 11:47:03 +0100 [thread overview]
Message-ID: <3304e0-66701400-f47-33d83680@2902777> (raw)
In-Reply-To: <20240617-emanzipation-ansiedeln-6fd2ae7659c8@brauner>
On Monday, June 17, 2024 11:48 EEST, Christian Brauner <brauner@kernel.org> wrote:
> On Thu, Jun 13, 2024 at 04:39:36PM GMT, Adrian Ratiu wrote:
> > The file struct is required in proc_mem_open() so its
> > f_mode can be checked when deciding whether to allow or
> > deny /proc/*/mem open requests via the new read/write
> > and foll_force restriction mechanism.
> >
> > Thus instead of directly passing the inode to the fun,
> > we pass the file and get the inode inside it.
> >
> > Cc: Jann Horn <jannh@google.com>
> > Cc: Kees Cook <keescook@chromium.org>
> > Cc: Christian Brauner <brauner@kernel.org>
> > Cc: Jeff Xu <jeffxu@google.com>
> > Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> > Reviewed-by: Kees Cook <kees@kernel.org>
> > ---
>
> I've tentatively applies this patch to #vfs.procfs.
> One comment, one question:
>
> > No changes in v6
> > ---
> > fs/proc/base.c | 6 +++---
> > fs/proc/internal.h | 2 +-
> > fs/proc/task_mmu.c | 6 +++---
> > fs/proc/task_nommu.c | 2 +-
> > 4 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/fs/proc/base.c b/fs/proc/base.c
> > index 72a1acd03675..4c607089f66e 100644
> > --- a/fs/proc/base.c
> > +++ b/fs/proc/base.c
> > @@ -794,9 +794,9 @@ static const struct file_operations proc_single_file_operations = {
> > };
> >
> >
> > -struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
> > +struct mm_struct *proc_mem_open(struct file *file, unsigned int mode)
> > {
> > - struct task_struct *task = get_proc_task(inode);
> > + struct task_struct *task = get_proc_task(file->f_inode);
>
> Comment: This should use file_inode(file) but I've just fixed that when I
> applied.
>
> Question: Is this an equivalent transformation. So is the inode that was
> passed to proc_mem_open() always the same inode as file_inode(file)?
Thank you!
Yes, the inode associated with the file struct should be always the same
while the file is opened, so the link set during the top-level mem_open()
callback should still hold while it itself calls into its sub-functions like
proc_mem_open().
prev parent reply other threads:[~2024-06-17 10:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 13:39 [PATCH v6 1/2] proc: pass file instead of inode to proc_mem_open Adrian Ratiu
2024-06-13 13:39 ` [PATCH v6 2/2] proc: restrict /proc/pid/mem Adrian Ratiu
2024-06-17 18:00 ` Kees Cook
2024-06-18 22:39 ` Jeff Xu
2024-06-19 20:41 ` Kees Cook
2024-06-19 21:31 ` Adrian Ratiu
2024-06-20 16:24 ` Jeff Xu
2024-06-17 8:48 ` [PATCH v6 1/2] proc: pass file instead of inode to proc_mem_open Christian Brauner
2024-06-17 10:47 ` Adrian Ratiu [this message]
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=3304e0-66701400-f47-33d83680@2902777 \
--to=adrian.ratiu@collabora.com \
--cc=ajordanr@google.com \
--cc=brauner@kernel.org \
--cc=gbiv@google.com \
--cc=inglorion@google.com \
--cc=jannh@google.com \
--cc=jeffxu@google.com \
--cc=jorgelo@chromium.org \
--cc=kees@kernel.org \
--cc=keescook@chromium.org \
--cc=kernel@collabora.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=ryanbeltran@google.com \
/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