From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: [PATCH 1/1] proc: make /proc/self point to thread Date: Tue, 27 Aug 2013 16:40:04 +0200 Message-ID: <20130827144004.GB19425@redhat.com> References: <20130825065039.GB9299@1wt.eu> <20130825194844.GA16717@redhat.com> <20130826153301.GA15890@redhat.com> <20130826163704.GA21763@redhat.com> <20130826175441.GA28856@redhat.com> <20130827143938.GA19425@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Willy Tarreau , Al Viro , Andy Lutomirski , Ingo Molnar , Linux Kernel Mailing List , Linux FS Devel , Brad Spengler To: Linus Torvalds , Andrew Morton , "Eric W. Biederman" Return-path: Content-Disposition: inline In-Reply-To: <20130827143938.GA19425@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org /proc/self points to /proc/, not to /proc/, and thus "self" actually means "group leader". Change fs/proc/self.c to print the caller's tid, this is probably what the users actually expect. Note: this is obviously semantically different and the difference is subtle, but most (all?) users should not notice this change. Lets see if it breaks something. Suggested-by: Linus Torvalds Signed-off-by: Oleg Nesterov --- fs/proc/self.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/proc/self.c b/fs/proc/self.c index 6b6a993..7da7154 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -11,26 +11,26 @@ 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); + pid_t tid = task_pid_nr_ns(current, ns); char tmp[PROC_NUMBUF]; - if (!tgid) + if (!tid) return -ENOENT; - sprintf(tmp, "%d", tgid); + sprintf(tmp, "%d", tid); 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); + pid_t tid = task_pid_nr_ns(current, ns); char *name = ERR_PTR(-ENOENT); - if (tgid) { + if (tid) { /* 11 for max length of signed int in decimal + NULL term */ name = kmalloc(12, GFP_KERNEL); if (!name) name = ERR_PTR(-ENOMEM); else - sprintf(name, "%d", tgid); + sprintf(name, "%d", tid); } nd_set_link(nd, name); return NULL; @@ -57,7 +57,7 @@ int proc_setup_self(struct super_block *s) struct inode *root_inode = s->s_root->d_inode; struct pid_namespace *ns = s->s_fs_info; struct dentry *self; - + mutex_lock(&root_inode->i_mutex); self = d_alloc_name(s->s_root, "self"); if (self) { -- 1.5.5.1