linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc: move the adding option Ngid to the end of proc/PID/status
@ 2015-04-17  2:13 Wang Xiaoming
  2015-04-17  2:56 ` Tejun Heo
  0 siblings, 1 reply; 17+ messages in thread
From: Wang Xiaoming @ 2015-04-17  2:13 UTC (permalink / raw)
  To: akpm, oleg, andriy.shevchenko, linux, ebiederm, eparis,
	chenhanxiao, tj, tglx, linux-kernel
  Cc: Wang Xiaoming, Schallberger, Timothy M, Dongxing Zhang

Move debugging has been done and the following Kernel issue
was found with a number of applications.
Take a look at: (even though the comments are for Weibo.browser
they also pertain to other apps that use Libsecuritysdk-x.x.x.so

In kernel(3.14) is a little different than before
it will generate /proc/PID/status in this way:
Name: a.weibo.browser
State: T (stopped)
Tgid: 8487
Ngid: 0     ---- add in kernel after (3.11 maybe)
Pid: 8487
PPid: 139
TracerPid: 0 ---------------------=> line 7
……

But on previous kernel(3.11), it normally like that:
Name: a.weibo.browser
State: S (sleeping)
Tgid: 2109
Pid: 2109
PPid: 231
TracerPid: 0 -----------------------=> line 6
……

WeiBo always assume the “TracePid” is in line 6 of the status.
And it will read “PPid: 139” instead of “TracePid: 0”,
which will made Weibo to kill the process because there is attached debugger.
This issue also met in other application.

As the Ngid is added later, so it should be added at the end of task_state.
It is better keeping compatible to avoid such issue.

Signed-off-by: Schallberger, Timothy M <timothy.m.schallberger@intel.com>
Signed-off-by: Dongxing Zhang <dongxing.zhang@intel.com>
Signed-off-by: Wang Xiaoming <xiaoming.wang@intel.com>
---
 fs/proc/array.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index fd02a9e..86dcd2b 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -163,15 +163,15 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
 	seq_printf(m,
 		"State:\t%s\n"
 		"Tgid:\t%d\n"
-		"Ngid:\t%d\n"
 		"Pid:\t%d\n"
 		"PPid:\t%d\n"
 		"TracerPid:\t%d\n"
 		"Uid:\t%d\t%d\t%d\t%d\n"
 		"Gid:\t%d\t%d\t%d\t%d\n"
+		"Ngid:\t%d\n"
 		"FDSize:\t%d\nGroups:\t",
 		get_task_state(p),
-		tgid, ngid, pid_nr_ns(pid, ns), ppid, tpid,
+		tgid, pid_nr_ns(pid, ns), ppid, tpid,
 		from_kuid_munged(user_ns, cred->uid),
 		from_kuid_munged(user_ns, cred->euid),
 		from_kuid_munged(user_ns, cred->suid),
@@ -180,6 +180,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
 		from_kgid_munged(user_ns, cred->egid),
 		from_kgid_munged(user_ns, cred->sgid),
 		from_kgid_munged(user_ns, cred->fsgid),
+		ngid,
 		max_fds);
 
 	group_info = cred->group_info;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: [PATCH] proc: move the adding option Ngid to the end of proc/PID/status
@ 2015-04-17 13:23 Alexey Dobriyan
  2015-04-17 14:26 ` Tejun Heo
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Dobriyan @ 2015-04-17 13:23 UTC (permalink / raw)
  To: xiaoming.wang, Tejun Heo; +Cc: Linux Kernel, mgorman, Andrew Morton

Tejun Heo wrote:
> On Fri, Apr 17, 2015 at 10:13:15AM +0800, Wang Xiaoming wrote:
> > Move debugging has been done and the following Kernel issue
> > was found with a number of applications.
> > Take a look at: (even though the comments are for Weibo.browser
> > they also pertain to other apps that use Libsecuritysdk-x.x.x.so
> >
> > In kernel(3.14) is a little different than before
> > it will generate /proc/PID/status in this way:
> > Name: a.weibo.browser
> > State: T (stopped)
> > Tgid: 8487
> > Ngid: 0     ---- add in kernel after (3.11 maybe)
>
> Well, that's kinda hilarious and I don't know.  3.11 is way back and
> what if there are others depending on the current ordering?  Both
> situations kinda suck so what's the point of changing?

It was demonstrated that Ngid addition as line 4 breaks apps,
but your "what if" remains "what if".

I'd say Ngid should be moved to the end and every new field
must be added to the end from now on, people can't parse
simple file correctly, let's not create problems for them.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-04-24 15:51 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-17  2:13 [PATCH] proc: move the adding option Ngid to the end of proc/PID/status Wang Xiaoming
2015-04-17  2:56 ` Tejun Heo
2015-04-17  3:15   ` Wang, Xiaoming
2015-04-17  3:26     ` Tejun Heo
2015-04-17  3:37       ` Wang, Xiaoming
2015-04-17  3:42         ` Tejun Heo
2015-04-17  5:36           ` Wang, Xiaoming
2015-04-21 15:19             ` Eric W. Biederman
2015-04-17 13:23 Alexey Dobriyan
2015-04-17 14:26 ` Tejun Heo
2015-04-17 15:05   ` Alexey Dobriyan
2015-04-17 15:12     ` Tejun Heo
2015-04-21  8:19       ` Wang, Xiaoming
2015-04-21 14:00       ` Alexey Dobriyan
2015-04-21 15:11         ` Tejun Heo
2015-04-23 20:32           ` Alexey Dobriyan
2015-04-24 15:50             ` Tejun Heo

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).