From: ebiederm@xmission.com (Eric W. Biederman)
To: Pavel Machek <pavel@ucw.cz>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
Jan Kara <jack@suse.cz>, "J. Bruce Fields" <bfields@fieldses.org>,
"Serge E. Hallyn" <serue@us.ibm.com>,
kernel list <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
jamie@shareable.org
Subject: Re: symlinks with permissions
Date: Thu, 29 Oct 2009 09:23:46 -0700 [thread overview]
Message-ID: <m1d4466uel.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20091029110344.GA1517@ucw.cz> (Pavel Machek's message of "Thu\, 29 Oct 2009 12\:03\:44 +0100")
Pavel Machek <pavel@ucw.cz> writes:
> Hi!
>
>> >> It looks to me like it has been this way for better than a decade
>> >> without problems so there is no point in changing it now.
>> >
>> > Unix compatibility?
>>
>> Thinking about this proc fundamentally gives you the ability to create
>> (via open) a new file descriptor for a file you already have open.
>
> Yes. Problem is that by using /proc, I can work-around open(READONLY)
> restriction and work-around open(APPEND_ONLY) restriction.
If you are allowed to do that simply opening the inode.
I can also use a bind mount on the file before you lock down
permissions instead of proc in your example to achieve the same
affect. An extra path to an inode.
In general there is not a way to lock down the path to a file to a
more restrictive set of permissions after it has been opened. Not
until sys_revoke or similar syscall has been implemented. Even then I
am a bit dubious.
>> I do see a security issue in your example, but the security issue I
>> see is how you have chosen to use the linux facilities, that have been
>> there for ages. Facilities cloned from plan 9 and apparently
>> available in slightly different forms on many unix variants existence.
>> /dev/fd/N is not a linuxism.
>>
>> To close this whole would require some sort of stacking inode that
>> when opened opened the real fs inode. With all kinds of convolutions
>> and complications. Just to close the issue that some idiot might
>> give someone a fd to a world writeable file that they don't want
>> them to open.
>
> Ok, so you agree issue is there. Good.
I don't agree that the kernel has a problem. I agree that there
is a security hole in your example.
I don't believe you can rely on the directory permissions in the general
case to control access to a file.
> Now, fix for READONLY issue should be fairly simple: follow link in
> /proc/*/fd/* should check the link permissions, and return
> read-only/write-only descriptors as neccessary.
The follow_link is just a follow link. Either we add an extra path
to the fd or we don't. Follow link doesn't know it is being used for open.
That isn't completely correct. You might be able to look at the
intent and if it is LOOKUP_OPEN and the open mode is compatible return
the original file descriptor. Even if you do that and the kernel is
guaranteed to take that path in all examples that still leaves an
extra path for syscalls that don't require a filedesciptor to use.
> Basically, that follow link should behave as dup(), not as open().
There are reasons why an open is an open here. I don't remember the
details but I found the archive of that conversation once. Maybe it was
just technical limitations of the time.
>> I certainly am not interested in debugging or maintaining the stacking
>> inode code that would be necessary to close this theoretical corner
>> case. There are much more real bugs that need attention.
>
> But if we can get trivial 10-liner, that should be acceptable, right?
How many linux shell scripts and other applications that use /dev/fd/N
or /proc/self/fd/N will you be breaking?
Closing a theoretical security hole at the expense of breaking real
applications is a show stopper.
Feel free to play and test but I'm still not buying it.
Eric
next prev parent reply other threads:[~2009-10-29 16:23 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-25 6:29 symlinks with permissions Pavel Machek
2009-10-26 16:31 ` Jan Kara
2009-10-26 16:57 ` Serge E. Hallyn
2009-10-26 17:36 ` J. Bruce Fields
2009-10-26 17:46 ` Jan Kara
2009-10-26 17:57 ` Trond Myklebust
2009-10-25 9:36 ` Pavel Machek
2009-10-26 18:22 ` Trond Myklebust
2009-10-27 8:11 ` Pavel Machek
2009-10-27 10:27 ` Jamie Lokier
2009-10-26 18:35 ` J. Bruce Fields
2009-10-28 4:15 ` Eric W. Biederman
2009-10-28 8:16 ` Pavel Machek
2009-10-28 11:25 ` Eric W. Biederman
2009-10-28 21:03 ` Pavel Machek
2009-10-29 2:20 ` Eric W. Biederman
2009-10-29 11:03 ` Pavel Machek
2009-10-29 16:23 ` Eric W. Biederman [this message]
2009-10-30 18:35 ` Pavel Machek
2009-10-30 20:37 ` Nick Bowler
2009-10-30 23:03 ` Eric W. Biederman
2009-10-31 2:30 ` Jamie Lokier
2009-10-28 16:34 ` Casey Schaufler
2009-10-28 19:44 ` Jamie Lokier
2009-10-28 21:06 ` Pavel Machek
2009-10-28 22:48 ` David Wagner
2009-10-29 4:13 ` Casey Schaufler
2009-10-29 7:53 ` David Wagner
2009-10-30 14:07 ` Pavel Machek
2009-10-31 4:09 ` Casey Schaufler
2009-11-01 9:23 ` David Wagner
2009-11-01 17:43 ` Casey Schaufler
2009-11-01 20:39 ` David Wagner
2009-11-01 22:05 ` Casey Schaufler
2009-10-26 18:02 ` J. Bruce Fields
2009-10-26 17:57 ` Serge E. Hallyn
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=m1d4466uel.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=bfields@fieldses.org \
--cc=jack@suse.cz \
--cc=jamie@shareable.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=serue@us.ibm.com \
--cc=trond.myklebust@fys.uio.no \
--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