From: Christian Brauner <brauner@kernel.org>
To: Dave Marchevsky <davemarchevsky@fb.com>
Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Rik van Riel <riel@surriel.com>,
Seth Forshee <sforshee@digitalocean.com>,
kernel-team <kernel-team@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
clm@fb.com
Subject: Re: [PATCH v2] fuse: Add module param for non-descendant userns access to allow_other
Date: Tue, 7 Jun 2022 10:47:24 +0200 [thread overview]
Message-ID: <20220607084724.7gseviks4h2seeza@wittgenstein> (raw)
In-Reply-To: <20220601184407.2086986-1-davemarchevsky@fb.com>
On Wed, Jun 01, 2022 at 11:44:07AM -0700, Dave Marchevsky wrote:
> Since commit 73f03c2b4b52 ("fuse: Restrict allow_other to the
> superblock's namespace or a descendant"), access to allow_other FUSE
> filesystems has been limited to users in the mounting user namespace or
> descendants. This prevents a process that is privileged in its userns -
> but not its parent namespaces - from mounting a FUSE fs w/ allow_other
> that is accessible to processes in parent namespaces.
>
> While this restriction makes sense overall it breaks a legitimate
> usecase: I have a tracing daemon which needs to peek into
> process' open files in order to symbolicate - similar to 'perf'. The
> daemon is a privileged process in the root userns, but is unable to peek
> into FUSE filesystems mounted with allow_other by processes in child
> namespaces.
>
> This patch adds a module param, allow_other_parent_userns, to act as an
> escape hatch for this descendant userns logic. Setting
> allow_other_parent_userns allows non-descendant-userns processes to
> access FUSEs mounted with allow_other. A sysadmin setting this param
> must trust allow_other FUSEs on the host to not DoS processes as
> described in 73f03c2b4b52.
>
> Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
> ---
>
> This is a followup to a previous attempt to solve same problem in a
> different way: "fuse: allow CAP_SYS_ADMIN in root userns to access
> allow_other mount" [0].
>
> v1 -> v2:
> * Use module param instead of capability check
>
> [0]: lore.kernel.org/linux-fsdevel/20211111221142.4096653-1-davemarchevsky@fb.com
>
> fs/fuse/dir.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 9dfee44e97ad..3d593ae7dc66 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -11,6 +11,7 @@
> #include <linux/pagemap.h>
> #include <linux/file.h>
> #include <linux/fs_context.h>
> +#include <linux/moduleparam.h>
> #include <linux/sched.h>
> #include <linux/namei.h>
> #include <linux/slab.h>
> @@ -21,6 +22,12 @@
> #include <linux/types.h>
> #include <linux/kernel.h>
>
> +static bool __read_mostly allow_other_parent_userns;
> +module_param(allow_other_parent_userns, bool, 0644);
> +MODULE_PARM_DESC(allow_other_parent_userns,
> + "Allow users not in mounting or descendant userns "
> + "to access FUSE with allow_other set");
The name of the parameter also suggests that access is granted to parent
userns tasks whereas the change seems to me to allows every task access
to that fuse filesystem independent of what userns they are in.
So even a task in a sibling userns could - probably with rather
elaborate mount propagation trickery - access that fuse filesystem.
AFaict, either the module parameter is misnamed or the patch doesn't
implement the behavior expressed in the name.
The original patch restricted access to a CAP_SYS_ADMIN capable task.
Did we agree that it was a good idea to weaken it to all tasks?
Shouldn't we still just restrict this to CAP_SYS_ADMIN capable tasks in
the initial userns?
> +
> static void fuse_advise_use_readdirplus(struct inode *dir)
> {
> struct fuse_inode *fi = get_fuse_inode(dir);
> @@ -1230,7 +1237,7 @@ int fuse_allow_current_process(struct fuse_conn *fc)
> const struct cred *cred;
>
> if (fc->allow_other)
> - return current_in_userns(fc->user_ns);
> + return current_in_userns(fc->user_ns) || allow_other_parent_userns;
>
> cred = current_cred();
> if (uid_eq(cred->euid, fc->user_id) &&
> --
> 2.30.2
>
next prev parent reply other threads:[~2022-06-07 8:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 18:44 [PATCH v2] fuse: Add module param for non-descendant userns access to allow_other Dave Marchevsky
2022-06-07 8:47 ` Christian Brauner [this message]
2022-06-10 21:37 ` Andrii Nakryiko
2022-06-13 8:23 ` Miklos Szeredi
2022-06-13 9:37 ` Christian Brauner
2022-06-13 10:34 ` Miklos Szeredi
2022-06-13 10:46 ` Christian Brauner
2022-06-13 13:22 ` Miklos Szeredi
2022-06-13 18:21 ` Andrii Nakryiko
2022-06-14 14:33 ` Christian Brauner
2022-06-15 23:36 ` Andrii Nakryiko
2022-06-16 8:01 ` Christian Brauner
2022-06-16 16:14 ` Dave Marchevsky
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=20220607084724.7gseviks4h2seeza@wittgenstein \
--to=brauner@kernel.org \
--cc=acme@kernel.org \
--cc=clm@fb.com \
--cc=davemarchevsky@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=riel@surriel.com \
--cc=sforshee@digitalocean.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;
as well as URLs for NNTP newsgroup(s).