Re: [PATCH] vfs: new O_NODE open flag

From: Florian Weimer
Date: Wed Sep 30 2009 - 04:18:43 EST


* Jamie Lokier:

> I hope the above cannot convert O_NOACCESS to O_RDWR without checking
> that you have access to the file.

It doesn't.

Here's what I did to reproduce:

$ mkdir /tmp/xyz
$ touch /tmp/xyz/123
$ tail -f /tmp/xyz/123

And in another terminal:

$ chmod 000 /tmp/xyz
$ echo foo > /tmp/xyz/123
bash: /tmp/xyz/123: Permission denied
$ $ echo foo > /proc/$pid_of_tail/fd/5

And the first terminal prints "foo". It fails if the file it self is
not writeable, only the access check on the path is bypassed. I still
think this is wrong.

FWIW, fcntl(F_SETFL) is documented to ignore O_RDWR etc. flags. For
/proc/PID/fd, it probably makes sense to check the current access
flags on the object, and the original open mode. Rechecking the path
seems impossible because it has unclear semantics.

The whole thing is a bit worrisome because it may turn file descriptor
information leaks into something worse.

--
Florian Weimer <fweimer@xxxxxx>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/