Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=488e5bc4560d0b510c1ddc451c51a6cc14e3a930
Commit:     488e5bc4560d0b510c1ddc451c51a6cc14e3a930
Parent:     df5f8314ca30d6a76735748e5ba4ca9809c0f434
Author:     Eric W. Biederman <[EMAIL PROTECTED]>
AuthorDate: Fri Feb 8 04:18:34 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Feb 8 09:22:24 2008 -0800

    proc: proper pidns handling for /proc/self
    
    Currently if you access a /proc that is not mounted with your processes
    current pid namespace /proc/self will point at a completely random task.
    
    This patch fixes /proc/self to point to the current process if it is
    available in the particular mount of /proc or to return -ENOENT if the
    current process is not visible.
    
    Signed-off-by: Eric W. Biederman <[EMAIL PROTECTED]>
    Cc: Pavel Emelyanov <[EMAIL PROTECTED]>
    Cc: Alexey Dobriyan <[EMAIL PROTECTED]>
    Cc: Oleg Nesterov <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/proc/base.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8a19a8a..75b1979 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2101,15 +2101,23 @@ static const struct file_operations 
proc_coredump_filter_operations = {
 static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
                              int buflen)
 {
+       struct pid_namespace *ns = dentry->d_sb->s_fs_info;
+       pid_t tgid = task_tgid_nr_ns(current, ns);
        char tmp[PROC_NUMBUF];
-       sprintf(tmp, "%d", task_tgid_vnr(current));
+       if (!tgid)
+               return -ENOENT;
+       sprintf(tmp, "%d", tgid);
        return vfs_readlink(dentry,buffer,buflen,tmp);
 }
 
 static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
+       struct pid_namespace *ns = dentry->d_sb->s_fs_info;
+       pid_t tgid = task_tgid_nr_ns(current, ns);
        char tmp[PROC_NUMBUF];
-       sprintf(tmp, "%d", task_tgid_vnr(current));
+       if (!tgid)
+               return ERR_PTR(-ENOENT);
+       sprintf(tmp, "%d", task_tgid_nr_ns(current, ns));
        return ERR_PTR(vfs_follow_link(nd,tmp));
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to