From: Paul Moore <paul@paul-moore.com>
To: omosnace@redhat.com
Cc: selinux@vger.kernel.org, ebiederm@xmission.com,
trond.myklebust@primarydata.com, seth.forshee@canonical.com,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] selinux: always allow mounting submounts
Date: Mon, 26 Nov 2018 18:25:30 -0500 [thread overview]
Message-ID: <CAHC9VhTvuPvnkfgQhT4+AM3iEz4_p85QgShM_oXmpVtLKuq10Q@mail.gmail.com> (raw)
In-Reply-To: <CAFqZXNvSdKYr998v3hEhZu4pRwuQs8Q7qRWPhOAtLAc9__Bs6w@mail.gmail.com>
On Wed, Nov 21, 2018 at 10:38 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> On Wed, Nov 21, 2018 at 1:41 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > On Tue, Nov 20, 2018 at 11:09 PM Paul Moore <paul@paul-moore.com> wrote:
> > > On Fri, Nov 16, 2018 at 8:12 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > > > If a superblock has the MS_SUBMOUNT flag set, we should always allow
> > > > mounting it. These mounts are done automatically by the kernel either as
> > > > part of mounting some parent mount (e.g. debugfs always mounts tracefs
> > > > under "tracing" for compatibility) or they are mounted automatically as
> > > > needed on subdirectory accesses (e.g. NFS crossmnt mounts). Since such
> > > > automounts are either an implicit consequence of the parent mount (which
> > > > is already checked) or they can happen during regular accesses (where it
> > > > doesn't make sense to check against the current task's context), the
> > > > mount permission check should be skipped for them.
> > > >
> > > > Without this patch, attempts to access contents of an automounted
> > > > directory can cause unexpected SELinux denials.
> > > >
> > > > In the current kernel tree, the MS_SUBMOUNT flag is set only via
> > > > vfs_submount(), which is called only from the following places:
> > > > - AFS, when automounting special "symlinks" referencing other cells
> > > > - CIFS, when automounting "referrals"
> > > > - NFS, when automounting subtrees
> > > > - debugfs, when automounting tracefs
> > > >
> > > > In all cases the submounts are meant to be transparent to the user and
> > > > it makes sense that if mounting the master is allowed, then so should be
> > > > the automounts. Note that CAP_SYS_ADMIN capability checking is already
> > > > skipped for (SB_KERNMOUNT|SB_SUBMOUNT) in:
> > > > - sget_userns() in fs/super.c:
> > > > if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) &&
> > > > !(type->fs_flags & FS_USERNS_MOUNT) &&
> > > > !capable(CAP_SYS_ADMIN))
> > > > return ERR_PTR(-EPERM);
> > > > - sget() in fs/super.c:
> > > > /* Ensure the requestor has permissions over the target filesystem */
> > > > if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
> > > > return ERR_PTR(-EPERM);
> > > >
> > > > Verified internally on patched RHEL 7.6 with a reproducer using
> > > > NFS+httpd and selinux-tesuite.
> > >
> > > I think this all sounds reasonable, but please verify this with an
> > > upstream kernel. Upstream our focus is on the upstream kernel
> > > (surprise!), downstream RHEL is your responsibility, not ours :)
> >
> > I tested on RHEL because that's what I can do most conveniently. I
> > don't have a very good workflow/environment for complex testing on
> > upstream right now. I don't expect the results to be any different on
> > the upstream kernel, but I understand your concern. I have been
> > thinking about some patch testing automation using Fedora Rawhide (I
> > hope that's close enough to upstream at least :), so I guess it's time
> > to get scriptin'...
>
> I have now tested it on Fedora Rawhide with a scratch kernel with this
> patch applied [1] (x86_64 only). I ran the whole selinux-testsuite
> with the submount test [2] and everything passed (except for the known
> overlay failures and skipped binder test) ...
Merged into selinux/next, thanks.
--
paul moore
www.paul-moore.com
next prev parent reply other threads:[~2018-11-27 10:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 13:12 [PATCH] selinux: always allow mounting submounts Ondrej Mosnacek
2018-11-19 13:15 ` Ondrej Mosnacek
2018-11-20 22:09 ` Paul Moore
2018-11-21 12:41 ` Ondrej Mosnacek
2018-11-21 15:38 ` Ondrej Mosnacek
2018-11-26 23:25 ` Paul Moore [this message]
2018-11-28 15:40 ` Eric W. Biederman
2018-11-28 16:12 ` Ondrej Mosnacek
2018-11-28 17:38 ` Eric W. Biederman
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=CAHC9VhTvuPvnkfgQhT4+AM3iEz4_p85QgShM_oXmpVtLKuq10Q@mail.gmail.com \
--to=paul@paul-moore.com \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=selinux@vger.kernel.org \
--cc=seth.forshee@canonical.com \
--cc=trond.myklebust@primarydata.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).