lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 21 Apr 2014 10:48:45 -0700
From:	Andy Lutomirski <luto@...capital.net>
To:	Al Viro <viro@...iv.linux.org.uk>
Cc:	Pavel Machek <pavel@....cz>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Linux FS Devel <linux-fsdevel@...r.kernel.org>,
	"Theodore Ts'o" <tytso@....edu>,
	David Herrmann <dh.herrmann@...il.com>
Subject: Re: [RFC 2/2] fs,proc: Respect FMODE_WRITE when opening /proc/pid/fd/N

On Mon, Apr 21, 2014 at 10:04 AM, Andy Lutomirski <luto@...capital.net> wrote:
> On Mon, Apr 21, 2014 at 10:00 AM, Andy Lutomirski <luto@...capital.net> wrote:
>> On Mon, Apr 21, 2014 at 9:30 AM, Al Viro <viro@...iv.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?
>
> No, I think that's wrong, too.  I think that will cause me to screw up
> symlinks to /proc/self/fd/3.  What's the right way to tell that
> follow_link is happening on the very last pathname component?
>
> Hmm.  I wonder what happens, or even what should happen, if the file
> descriptor is a symlink opened with O_PATH | O_NOFOLLOW.

Here's a test case:

https://github.com/amluto/procfd_test

It doesn't cover O_PATH yet.

Both my code and current kernels fail.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ