netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Pavel Emelyanov <xemul@openvz.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Pavel Machek <pavel@ucw.cz>,
	kernel list <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] proc: Fix the threaded /proc/self.
Date: Tue, 20 Nov 2007 15:41:12 -0700	[thread overview]
Message-ID: <m1k5ocr14n.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20071120215914.GE24156@elte.hu> (Ingo Molnar's message of "Tue, 20 Nov 2007 22:59:14 +0100")


Long ago when the CLONE_THREAD support first went it someone
thought it would be wise to point /proc/self at /proc/<tgid>
instead of /proc/<pid>.

Given that /proc/<tgid> can return information about a very different
task (if enough things have been unshared) then our current process
/proc/<tgid> seems blatantly wrong.  So far I have yet to think up
an example where the current behavior would be advantageous, and
I can see several places where it is seriously non-intuitive.

We may be stuck with the current broken behavior for backwards
compatibility reasons but lets try fixing our ancient bug for the
2.6.25 time frame and see if anyone screams.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 fs/proc/base.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 34a1821..8502436 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2050,22 +2050,22 @@ 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 pid = task_pid_nr_ns(current, ns);
 	char tmp[PROC_NUMBUF];
-	if (!tgid)
+	if (!pid)
 		return -ENOENT;
-	sprintf(tmp, "%d", tgid);
+	sprintf(tmp, "%d", pid);
 	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 pid = task_pid_nr_ns(current, ns);
 	char tmp[PROC_NUMBUF];
-	if (!tgid)
+	if (!pid)
 		return ERR_PTR(-ENOENT);
-	sprintf(tmp, "%d", task_tgid_nr_ns(current, ns));
+	sprintf(tmp, "%d", pid);
 	return ERR_PTR(vfs_follow_link(nd,tmp));
 }
 
-- 
1.5.3.rc6.17.g1911


  parent reply	other threads:[~2007-11-20 22:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071119191000.GA1560@elf.ucw.cz>
2007-11-19 22:04 ` 2.6.24-rc3: find complains about /proc/net Rafael J. Wysocki
2007-11-20 15:51   ` Pavel Emelyanov
2007-11-20 21:52     ` Eric W. Biederman
2007-11-20 21:59       ` Ingo Molnar
2007-11-20 22:17         ` Eric W. Biederman
2007-11-20 22:35           ` Ingo Molnar
2007-11-20 22:54             ` Roland McGrath
2007-11-20 23:01               ` Ingo Molnar
2007-11-20 23:06                 ` Guillaume Chazarain
2007-11-20 23:26                   ` Roland McGrath
2007-11-20 23:32                     ` Ulrich Drepper
2007-11-20 23:45                       ` Ingo Molnar
2007-11-20 23:51                         ` Roland McGrath
2007-11-21  0:47                           ` Eric W. Biederman
2007-11-21  1:01                           ` Rafael J. Wysocki
2007-11-21  0:41                       ` Eric W. Biederman
2007-11-20 23:43                   ` Ingo Molnar
2007-11-20 22:41         ` Eric W. Biederman [this message]
2007-11-20 22:58           ` [PATCH] proc: Fix the threaded /proc/self Guillaume Chazarain
2007-11-20 23:03           ` Ingo Molnar
2007-11-21  1:19     ` 2.6.24-rc3: find complains about /proc/net Eric W. Biederman
2007-11-21  6:36     ` Eric W. Biederman
2007-11-21  9:36       ` Pavel Emelyanov
2007-11-24 23:34     ` [CFT][PATCH] proc_net: Remove userspace visible changes Eric W. Biederman
2007-11-26  8:43       ` Eric W. Biederman
2007-11-26 22:17     ` [PATCH 2.6.24-rc3] Fix /proc/net breakage Eric W. Biederman
2007-11-27 11:20       ` Pavel Emelyanov
2007-11-27 12:36         ` Eric W. Biederman
2007-12-07  4:51       ` David Woodhouse
2007-12-07 10:23         ` Andrew Morton
2007-12-07 11:11           ` Denis V. Lunev
2007-12-27 17:40           ` Andreas Mohr
2007-12-27 18:41             ` Alexey Dobriyan
2007-12-27 22:17               ` Andreas Mohr
2007-12-28  6:22                 ` Alexey Dobriyan
2007-12-28  7:21                   ` Andreas Mohr
2007-12-30 16:14                     ` [usb regression] " Ingo Molnar
2007-12-30 20:34                       ` Alan Stern
2007-12-31  5:25                         ` Greg KH
2007-12-31 17:49                           ` Alan Stern
2007-12-31 19:26                             ` Greg KH
2008-01-02  6:00                               ` Greg KH
2008-01-02  6:13                                 ` Andreas Mohr
     [not found]                                   ` <20080102061308.GB30929-p/qQFhXj4MHA4IYVXhSI5GHfThorsUsI@public.gmane.org>
2008-01-02  7:14                                     ` Greg KH
     [not found]                                 ` <20080102060006.GA27693-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2008-01-02 15:56                                   ` Alan Stern
     [not found]                                     ` <Pine.LNX.4.44L0.0801021052470.4861-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2008-01-02 18:48                                       ` David Brownell
2008-01-02  6:04                         ` Andreas Mohr

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=m1k5ocr14n.fsf_-_@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    --cc=xemul@openvz.org \
    /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;
as well as URLs for NNTP newsgroup(s).