linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tyler Hicks <code@tyhicks.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: "Christian Brauner" <brauner@kernel.org>,
	"Günther Noack" <gnoack3000@gmail.com>,
	landlock@lists.linux.dev,
	linux-security-module <linux-security-module@vger.kernel.org>,
	Linux-Fsdevel <linux-fsdevel@vger.kernel.org>,
	"Al Viro" <viro@zeniv.linux.org.uk>
Subject: Re: Does Landlock not work with eCryptfs?
Date: Fri, 24 Mar 2023 17:53:20 -0500	[thread overview]
Message-ID: <ZB4p4DXwgByYCt5O@sequoia> (raw)
In-Reply-To: <42ffeef4-e71f-dd2b-6332-c805d1db2e3f@digikod.net>

On 2023-03-21 19:16:28, Mickaël Salaün wrote:
> 
> On 21/03/2023 18:24, Christian Brauner wrote:
> > On Tue, Mar 21, 2023 at 05:36:19PM +0100, Mickaël Salaün wrote:
> > > There is an inconsistency between ecryptfs_dir_open() and ecryptfs_open().
> > > ecryptfs_dir_open() actually checks access right to the lower directory,
> > > which is why landlocked processes may not access the upper directory when
> > > reading its content. ecryptfs_open() uses a cache for upper files (which
> > > could be a problem on its own). The execution flow is:
> > > 
> > > ecryptfs_open() -> ecryptfs_get_lower_file() -> ecryptfs_init_lower_file()
> > > -> ecryptfs_privileged_open()
> > > 
> > > In ecryptfs_privileged_open(), the dentry_open() call failed if access to
> > > the lower file is not allowed by Landlock (or other access-control systems).
> > > Then wait_for_completion(&req.done) waits for a kernel's thread executing
> > > ecryptfs_threadfn(), which uses the kernel's credential to access the lower
> > > file.
> > > 
> > > I think there are two main solutions to fix this consistency issue:
> > > - store the mounter credentials and uses them instead of the kernel's
> > > credentials for lower file and directory access checks (ecryptfs_dir_open
> > > and ecryptfs_threadfn changes);
> > > - use the kernel's credentials for all lower file/dir access check,
> > > especially in ecryptfs_dir_open().
> > > 
> > > I think using the mounter credentials makes more sense, is much safer, and
> > > fits with overlayfs. It may not work in cases where the mounter doesn't have
> > > access to the lower file hierarchy though.
> > > 
> > > File creation calls vfs_*() helpers (lower directory) and there is not path
> > > nor file security hook calls for those, so it works unconditionally.
> > > 
> > >  From Landlock end users point of view, it makes more sense to grants access
> > > to a file hierarchy (where access is already allowed) and be allowed to
> > > access this file hierarchy, whatever it belongs to a specific filesystem
> > > (and whatever the potential lower file hierarchy, which may be unknown to
> > > users). This is how it works for overlayfs and I'd like to have the same
> > > behavior for ecryptfs.
> > 
> > So given that ecryptfs is marked as "Odd Fixes" who is realistically
> > going to do the work of switching it to a mounter's credentials model,
> > making sure this doesn't regress anything, and dealing with any
> > potential bugs caused by this. It might be potentially better to just
> > refuse to combine Landlock with ecryptfs if that's possible.
> 
> If Tyler is OK with the proposed solutions, I'll get a closer look at it in
> a few months. If anyone is interested to work on that, I'd be happy to
> review and test (the Landlock part).

I am alright with using the mounter creds but eCryptfs is typically
mounted as root using a PAM module so the mounter is typically going to
be more privileged than the user accessing the eCryptfs mount (in the
common case of an encrypted home directory).

But, as Christian points out, I think it might be better to make
Landlock refuse to work with eCryptfs. Would you be at ease with that
decision if we marked eCryptfs as deprecated with a planned removal
date?

Tyler


  parent reply	other threads:[~2023-03-24 22:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230319.2139b35f996f@gnoack.org>
2023-03-19 21:00 ` Does Landlock not work with eCryptfs? Mickaël Salaün
2023-03-20 17:15   ` Günther Noack
2023-03-20 17:21     ` Mickaël Salaün
2023-03-21 16:36       ` Mickaël Salaün
2023-03-21 17:24         ` Christian Brauner
2023-03-21 18:16           ` Mickaël Salaün
2023-03-23 17:05             ` Günther Noack
2023-03-24 22:45               ` Tyler Hicks (Microsoft)
2023-03-24 22:53             ` Tyler Hicks [this message]
2023-03-26 21:19               ` Mickaël Salaün
2023-03-27 21:01                 ` Günther Noack

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=ZB4p4DXwgByYCt5O@sequoia \
    --to=code@tyhicks.com \
    --cc=brauner@kernel.org \
    --cc=gnoack3000@gmail.com \
    --cc=landlock@lists.linux.dev \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=viro@zeniv.linux.org.uk \
    /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).