From: Andy Lutomirski <luto@amacapital.net>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Pavel Machek <pavel@ucw.cz>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
"Theodore Ts'o" <tytso@mit.edu>,
David Herrmann <dh.herrmann@gmail.com>
Subject: Re: [RFC 2/2] fs,proc: Respect FMODE_WRITE when opening /proc/pid/fd/N
Date: Mon, 21 Apr 2014 10:00:55 -0700 [thread overview]
Message-ID: <CALCETrUJNv48UXPNSXcdnsFZSLwhRtA0s03bJHamXQmr6vs3fQ@mail.gmail.com> (raw)
In-Reply-To: <20140421163058.GS18016@ZenIV.linux.org.uk>
On Mon, Apr 21, 2014 at 9:30 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Mon, Apr 21, 2014 at 09:22:48AM -0700, Andy Lutomirski wrote:
>
>> +static int proc_may_follow(struct nameidata *nd, struct file *f)
>> +{
>> + if (!nd)
>> + return 0; /* This is readlink, */
>> +
>> + if ((nd->flags & LOOKUP_WRITE) && !(f->f_mode & FMODE_WRITE))
>> + return -EACCES;
>> +
>> + return 0;
>> +}
>
> And this is just plain wrong. WTF are you making the traversal of symlink
> in the middle of pathname dependent on the open flags?
Can you give me a hint? There are three cases that I need to
distinguish, I think:
1. readlink. Currently handled by nd == NULL. It's ugly, and I'll clean it up.
2. Traversal in the middle of a path. This can be either literally in
the middle (e.g. "/proc/self/fd/3/something_else") or in a symlink
that's the last component of the literal path (e.g. "fd3null" where
"fd3null" is a symlink to "/proc/self/fd/3/null" and "null" is either
a file or a symlink to /dev/null). I have the latter type wrong in
this patch.
3. Actually opening /proc/self/fd/N. This can be direct or by opening
a symlink to /proc/self/fd/N. I think I have this case correct.
What's the best way to fix this? Should I be checking nd->depth?
--Andy
>
> NAK.
--
Andy Lutomirski
AMA Capital Management, LLC
next prev parent reply other threads:[~2014-04-21 17:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-21 16:22 [RFC 0/2] Fix permission checks on open("/proc/self/fd/N", O_RDWR) Andy Lutomirski
2014-04-21 16:22 ` [RFC 1/2] fs,proc: Pass nameidata to proc_get_link implementations Andy Lutomirski
2014-04-21 16:29 ` Al Viro
2014-04-21 16:22 ` [RFC 2/2] fs,proc: Respect FMODE_WRITE when opening /proc/pid/fd/N Andy Lutomirski
2014-04-21 16:30 ` Al Viro
2014-04-21 17:00 ` Andy Lutomirski [this message]
2014-04-21 17:04 ` Andy Lutomirski
2014-04-21 17:48 ` Andy Lutomirski
2014-04-22 12:44 ` David Herrmann
2014-04-22 13:49 ` Andy Lutomirski
2014-04-22 14:17 ` David Herrmann
2014-04-22 14:33 ` Andy Lutomirski
2014-04-22 15:03 ` David Herrmann
2014-04-22 15:20 ` Andy Lutomirski
2014-04-22 14:40 ` Pavel Machek
2014-04-22 14:31 ` Pavel Machek
2014-04-22 15:19 ` David Herrmann
2014-04-22 15:24 ` Andy Lutomirski
2014-04-22 16:44 ` David Herrmann
2014-04-22 17:05 ` Andy Lutomirski
2014-04-22 18:58 ` Pavel Machek
2014-04-22 21:31 ` David Herrmann
2014-04-22 21:34 ` Andy Lutomirski
2014-04-22 22:12 ` Pavel Machek
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=CALCETrUJNv48UXPNSXcdnsFZSLwhRtA0s03bJHamXQmr6vs3fQ@mail.gmail.com \
--to=luto@amacapital.net \
--cc=dh.herrmann@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tytso@mit.edu \
--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).