diff options
author | Alexey Dobriyan <adobriyan@openvz.org> | 2007-05-08 03:23:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:14:58 -0400 |
commit | 8948e11f450e6189a79e47d6051c3d5a0b98e3f3 (patch) | |
tree | 8cc904873cc1a8506970cf1e4a328c318a7fc4d7 | |
parent | ab1b6f03a10ba1f5638188ab06bf46e33ac3a160 (diff) |
Allow access to /proc/$PID/fd after setuid()
/proc/$PID/fd has r-x------ permissions, so if process does setuid(), it
will not be able to access /proc/*/fd/. This breaks fstatat() emulation
in glibc.
open("foo", O_RDONLY|O_DIRECTORY) = 4
setuid32(65534) = 0
stat64("/proc/self/fd/4/bar", 0xbfafb298) = -1 EACCES (Permission denied)
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: James Morris <jmorris@namei.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Acked-By: Kirill Korotaev <dev@openvz.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/proc/base.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index ec158dd02b3a..a721acfd4fdc 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1448,10 +1448,28 @@ static const struct file_operations proc_fd_operations = { | |||
1448 | }; | 1448 | }; |
1449 | 1449 | ||
1450 | /* | 1450 | /* |
1451 | * /proc/pid/fd needs a special permission handler so that a process can still | ||
1452 | * access /proc/self/fd after it has executed a setuid(). | ||
1453 | */ | ||
1454 | static int proc_fd_permission(struct inode *inode, int mask, | ||
1455 | struct nameidata *nd) | ||
1456 | { | ||
1457 | int rv; | ||
1458 | |||
1459 | rv = generic_permission(inode, mask, NULL); | ||
1460 | if (rv == 0) | ||
1461 | return 0; | ||
1462 | if (task_pid(current) == proc_pid(inode)) | ||
1463 | rv = 0; | ||
1464 | return rv; | ||
1465 | } | ||
1466 | |||
1467 | /* | ||
1451 | * proc directories can do almost nothing.. | 1468 | * proc directories can do almost nothing.. |
1452 | */ | 1469 | */ |
1453 | static const struct inode_operations proc_fd_inode_operations = { | 1470 | static const struct inode_operations proc_fd_inode_operations = { |
1454 | .lookup = proc_lookupfd, | 1471 | .lookup = proc_lookupfd, |
1472 | .permission = proc_fd_permission, | ||
1455 | .setattr = proc_setattr, | 1473 | .setattr = proc_setattr, |
1456 | }; | 1474 | }; |
1457 | 1475 | ||