Re: [PATCH v15 3/9] namei: LOOKUP_NO_XDEV: block mountpoint crossing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH v15 3/9] namei: LOOKUP_NO_XDEV: block mountpoint crossing
- From: Aleksa Sarai <cyphar@xxxxxxxxxx>
- Date: Thu, 14 Nov 2019 15:49:45 +1100
- Cc: Jeff Layton <jlayton@xxxxxxxxxx>, "J. Bruce Fields" <bfields@xxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, David Howells <dhowells@xxxxxxxxxx>, Shuah Khan <shuah@xxxxxxxxxx>, Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Christian Brauner <christian.brauner@xxxxxxxxxx>, David Drysdale <drysdale@xxxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Eric Biederman <ebiederm@xxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Alexei Starovoitov <ast@xxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, Jann Horn <jannh@xxxxxxxxxx>, Tycho Andersen <tycho@xxxxxxxx>, Chanho Min <chanho.min@xxxxxxx>, Oleg Nesterov <oleg@xxxxxxxxxx>, Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>, Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>, Jiri Olsa <jolsa@xxxxxxxxxx>, Namhyung Kim <namhyung@xxxxxxxxxx>, Christian Brauner <christian@xxxxxxxxxx>, Aleksa Sarai <asarai@xxxxxxx>, containers@xxxxxxxxxxxxxxxxxxxxxxxxxx, linux-alpha@xxxxxxxxxxxxxxx, linux-api@xxxxxxxxxxxxxxx, libc-alpha@xxxxxxxxxxxxxx, linux-arch@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-kselftest@xxxxxxxxxxxxxxx, linux-m68k@xxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, linux-xtensa@xxxxxxxxxxxxxxxx, sparclinux@xxxxxxxxxxxxxxx
- In-reply-to: <20191113013630.GZ26530@ZenIV.linux.org.uk>
- References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-4-cyphar@cyphar.com> <20191113013630.GZ26530@ZenIV.linux.org.uk>
On 2019-11-13, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> On Tue, Nov 05, 2019 at 08:05:47PM +1100, Aleksa Sarai wrote:
>
> > @@ -862,6 +870,8 @@ static int nd_jump_root(struct nameidata *nd)
> > void nd_jump_link(struct path *path)
> > {
> > struct nameidata *nd = current->nameidata;
> > +
> > + nd->last_magiclink.same_mnt = (nd->path.mnt == path->mnt);
> > path_put(&nd->path);
> >
> > nd->path = *path;
> > @@ -1082,6 +1092,10 @@ const char *get_link(struct nameidata *nd)
> > if (nd->flags & LOOKUP_MAGICLINK_JUMPED) {
> > if (unlikely(nd->flags & LOOKUP_NO_MAGICLINKS))
> > return ERR_PTR(-ELOOP);
> > + if (unlikely(nd->flags & LOOKUP_NO_XDEV)) {
> > + if (!nd->last_magiclink.same_mnt)
> > + return ERR_PTR(-EXDEV);
> > + }
> > }
>
> Ugh... Wouldn't it be better to take that logics (some equivalent thereof)
> into nd_jump_link()? Or just have nd_jump_link() return an error...
This could be done, but the reason for stashing it away in
last_magiclink is because of the future magic-link re-opening patches
which can't be implemented like that without putting the open_flags
inside nameidata (which was decided to be too ugly a while ago).
My point being that I could implement it this way for this series, but
I'd have to implement something like last_magiclink when I end up
re-posting the magic-link stuff in a few weeks.
Looking at all the nd_jump_link() users, the other option is to just
disallow magic-link crossings entirely for LOOKUP_NO_XDEV. The only
thing allowing them permits is to resolve file descriptors that are
pointing to the same procfs mount -- and it's unclear to me how useful
that really is (apparmorfs and nsfs will always give -EXDEV because
aafs_mnt and nsfs_mnt are internal kernel vfsmounts).
--
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
Attachment:
signature.asc
Description: PGP signature
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]