From: "Eric W.Biederman" <ebiederm@xmission.com>
To: Andy Lutomirski <luto@amacapital.net>, Al Viro <viro@zeniv.linux.org.uk>
Cc: David Drysdale <drysdale@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Kees Cook <keescook@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Meredydd Luff <meredydd@senatehouse.org>,
Will Drewry <wad@chromium.org>,
Jorge Lucangeli Obes <jorgelo@google.com>,
Ricky Zhou <rickyz@google.com>, Lee Campbell <leecam@google.com>,
Julien Tinnes <jln@google.com>,
Mike Depinet <mdepinet@google.com>,
James Morris <james.l.morris@oracle.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Paul Moore <paul@paul-moore.com>,
Christoph Hellwig <hch@infradead.org>,
Linux API <linux-api@vger.kernel.org>,
LSM List <linux-security-module@vger.kernel.org>
Subject: Re: [PATCH 1/3] fs: add O_BENEATH flag to openat(2)
Date: Mon, 03 Nov 2014 09:22:38 -0800 [thread overview]
Message-ID: <d0973f4d-e8a4-4c5c-8bd1-1b1cb1f080b5@email.android.com> (raw)
In-Reply-To: <CALCETrWmivJCvAAZPQo9Jf5gDiSbpWKesjZWfqEQRXPOBSPY9g@mail.gmail.com>
On November 3, 2014 7:42:58 AM PST, Andy Lutomirski <luto@amacapital.net> wrote:
>On Mon, Nov 3, 2014 at 7:20 AM, Al Viro <viro@zeniv.linux.org.uk>
>wrote:
>> On Mon, Nov 03, 2014 at 11:48:23AM +0000, David Drysdale wrote:
>>> Add a new O_BENEATH flag for openat(2) which restricts the
>>> provided path, rejecting (with -EACCES) paths that are not beneath
>>> the provided dfd. In particular, reject:
>>> - paths that contain .. components
>>> - paths that begin with /
>>> - symlinks that have paths as above.
>>
>> Yecch... The degree of usefulness aside (and I'm not convinced that
>it
>> is non-zero),
>
>This is extremely useful in conjunction with seccomp.
>
>> WTF pass one bit out of nameidata->flags in a separate argument?
>> Through the mutual recursion, no less... And then you are not even
>attempting
>> to detect symlinks that are not followed by interpretation of _any_
>pathname.
>
>How many symlinks like that are there? Is there anything except
>nd_jump_link users? All of those are in /proc. Arguably O_BENEATH
>should prevent traversal of all of those links.
Not commenting on the sanity of this one way or another, and I haven't read the patch. There is an absolutely trivial implementation of this.
After the path is resolved, walk backwards along d_parent and the mount tree, and see if you come to the file or directory dfd refers to.
That can handle magic proc symlinks, and does not need to disallow .. or / explicitly so it should be much simpler code.
My gut says that if Al says blech when looking at your code it is too complex to give you a security guarantee.
Eric
next prev parent reply other threads:[~2014-11-03 17:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-03 11:48 [PATCH 0/3] " David Drysdale
2014-11-03 11:48 ` [PATCH 1/3] " David Drysdale
2014-11-03 15:20 ` Al Viro
2014-11-03 15:42 ` Andy Lutomirski
2014-11-03 17:22 ` Eric W.Biederman [this message]
2014-11-04 9:40 ` David Drysdale
2014-11-05 17:21 ` David Drysdale
2014-11-05 17:28 ` Andy Lutomirski
2014-11-03 17:37 ` David Drysdale
2014-11-03 18:26 ` Julien Tinnes
[not found] ` <CAKyRK=hRX1xk_0cRNhZ341HwU9Nim5_vhpM5twJHUOt8fH29=w@mail.gmail.com>
2014-11-03 18:29 ` Andy Lutomirski
2014-11-03 11:48 ` [PATCH 2/3] selftests: Add test of O_BENEATH & openat(2) David Drysdale
2014-11-03 11:48 ` [PATCH man-pages 3/3] open.2: describe O_BENEATH flag David Drysdale
2014-11-03 11:56 ` Paolo Bonzini
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=d0973f4d-e8a4-4c5c-8bd1-1b1cb1f080b5@email.android.com \
--to=ebiederm@xmission.com \
--cc=drysdale@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=james.l.morris@oracle.com \
--cc=jln@google.com \
--cc=jorgelo@google.com \
--cc=keescook@chromium.org \
--cc=leecam@google.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mdepinet@google.com \
--cc=meredydd@senatehouse.org \
--cc=paul@paul-moore.com \
--cc=pbonzini@redhat.com \
--cc=rickyz@google.com \
--cc=viro@zeniv.linux.org.uk \
--cc=wad@chromium.org \
/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
Powered by JetHome