From: Aleksa Sarai <email@example.com>
To: Al Viro <firstname.lastname@example.org>,
Eric Biederman <email@example.com>
Cc: Aleksa Sarai <firstname.lastname@example.org>,
Jeff Layton <email@example.com>,
"J. Bruce Fields" <firstname.lastname@example.org>,
Arnd Bergmann <email@example.com>, Andy Lutomirski <firstname.lastname@example.org>,
David Howells <email@example.com>, Jann Horn <firstname.lastname@example.org>,
Christian Brauner <email@example.com>,
Tycho Andersen <firstname.lastname@example.org>,
David Drysdale <email@example.com>,
Subject: [PATCH v2 0/3] namei: implement various lookup restriction AT_* flags
Date: Tue, 9 Oct 2018 17:52:56 +1100 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
The need for some sort of control over VFS's path resolution (to avoid
malicious paths resulting in inadvertent breakouts) has been a very
long-standing desire of many userspace applications. This patchset is a
revival of Al Viro's old AT_NO_JUMPS[1,2] patchset (which was a variant
of David Drysdale's O_BENEATH patchset which was a spin-off of the
capsicum patchset) with a few additions and changes made based on the
previous discussion within  as well as others I felt were useful.
As per the discussion in the AT_NO_JUMPS thread, AT_NO_JUMPS has been
split into separate flags.
* AT_XDEV blocks mountpoint crossings (both upwards and downwards).
openat("/", "tmp", AT_XDEV); // blocked
openat("/tmp", "..", AT_XDEV); // blocked
openat("/tmp", "/", AT_XDEV); // blocked
* AT_NO_PROCLINKS blocks all resolution through /proc/$pid/fd/$fd
"symlinks". Specifically, this blocks all jumps caused by a
filesystem using nd_jump_link() to shove you around in the
filesystem tree (these are referred to as "proclinks" in lieu of a
* AT_BENEATH disallows escapes from the starting dirfd using ".." or
absolute paths (either in the path or during symlink resolution).
Conceptually this flag ensures that you "stay below" the starting
point in the filesystem tree. ".." resolution is allowed if it
doesn't land you outside of the starting point (this is made safe
against races by patch 3 in this series).
AT_BENEATH also currently disallows all "proclink" resolution
because they can trivially throw you outside of the starting point.
In a future patch we might allow such resolution (as long as it
stays within the root).
In addition, two more flags have been added to the series:
* AT_NO_SYMLINKS disallows *all* symlink resolution, and thus implies
AT_NO_PROCLINKS. Linus mentioned this is something that git would
like to have in the original discussion.
* AT_THIS_ROOT is a very similar idea to AT_BENEATH, but it serves a
very different purpose. Rather than blocking resolutions if they
would go outside of the starting point, it treats the starting point
as a form of chroot(2). Container runtimes are one of the primary
justifications for this flag, as they currently have to implement
this sort of path handling racily in userspace.
The restrictions on "proclink" resolution are the same as with
AT_BENEATH (though in AT_THIS_ROOT's case it's not really clear how
"proclink" jumps outside of the root should be handled), and patch 3
in this series was also required to make ".." resolution safe.
* Made ".." resolution with AT_THIS_ROOT and AT_BENEATH safe by
through __d_path checking (see patch 3).
* Disallowed "proclinks" with AT_THIS_ROOT and AT_BENEATH, in the
hopes they can be re-enabled once safe.
* Removed the selftests as they will be reimplemented as xfstests.
Aleksa Sarai (3):
namei: implement O_BENEATH-style AT_* flags
namei: implement AT_THIS_ROOT chroot-like path resolution
namei: aggressively check nd->root on ".." resolution
fs/fcntl.c | 2 +-
fs/namei.c | 192 ++++++++++++++++++++++---------
fs/open.c | 10 ++
fs/stat.c | 4 +-
include/linux/fcntl.h | 3 +-
include/linux/namei.h | 8 ++
include/uapi/asm-generic/fcntl.h | 20 ++++
include/uapi/linux/fcntl.h | 10 ++
8 files changed, 193 insertions(+), 56 deletions(-)
next reply other threads:[~2018-10-09 6:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 6:52 Aleksa Sarai [this message]
2018-10-09 6:52 ` [PATCH v2 0/3] namei: implement various lookup restriction AT_* flags Aleksa Sarai
2018-10-09 6:52 ` [PATCH v2 1/3] namei: implement O_BENEATH-style " Aleksa Sarai
2018-10-09 19:25 ` Andy Lutomirski
2018-10-10 7:07 ` Aleksa Sarai
2018-10-10 7:28 ` Aleksa Sarai
2018-10-12 1:12 ` Andy Lutomirski
2018-10-27 1:41 ` Ed Maste
2018-10-27 7:17 ` Aleksa Sarai
2018-10-27 7:53 ` Al Viro
2018-10-27 12:11 ` : " Ed Maste
2018-10-27 15:37 ` Aleksa Sarai
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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).