From: Alexey Dobriyan <adobriyan@openvz.org>
To: akpm@osdl.org
Cc: pasky@suse.cz, linux-kernel@vger.kernel.org, devel@openvz.org
Subject: [RFC] Allow access to /proc/$PID/fd after setuid()
Date: Thu, 1 Feb 2007 18:04:34 +0300 [thread overview]
Message-ID: <20070201150434.GA6023@localhost.sw.ru> (raw)
/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>
---
fs/proc/base.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1413,11 +1413,27 @@ static struct file_operations proc_fd_op
.readdir = proc_readfd,
};
+static int proc_fd_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+ struct task_struct *tsk;
+ int rv;
+
+ rv = generic_permission(inode, mask, NULL);
+ if (rv == 0)
+ return 0;
+ tsk = get_proc_task(inode);
+ if (tsk == current)
+ rv = 0;
+ put_task_struct(tsk);
+ return rv;
+}
+
/*
* proc directories can do almost nothing..
*/
static struct inode_operations proc_fd_inode_operations = {
.lookup = proc_lookupfd,
+ .permission = proc_fd_permission,
.setattr = proc_setattr,
};
next reply other threads:[~2007-02-01 14:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-01 15:04 Alexey Dobriyan [this message]
2007-02-01 15:16 ` [Devel] [RFC] Allow access to /proc/$PID/fd after setuid() Kirill Korotaev
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=20070201150434.GA6023@localhost.sw.ru \
--to=adobriyan@openvz.org \
--cc=akpm@osdl.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pasky@suse.cz \
/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