Skip to contentSkip to conversation

proc: move the adding option Ngid to the end of proc/PID/status

PATCH In review Wang Xiaoming 3 participants 8 messages Apr 17, 2015 – Apr 21, 2015 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: move the adding option Ngid to the end of proc/PID/status

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.

---
 fs/proc/array.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/proc/array.c +3 -2
index fd02a9e..86dcd2b 100644
@@ -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;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 11 lines · Wang Xiaoming

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?

Signature · 1 line
tejun
#2 lore raw

Dear tejun

Quoted 25 lines

-----Original Message-----
From: Tejun Heo [mailto:[email protected]] On Behalf Of Tejun Heo
Sent: Friday, April 17, 2015 10:56 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Schallberger, Timothy M; Zhang, Dongxing
Subject: Re: [PATCH] proc: move the adding option Ngid to the end of proc/PID/status

Quoted 11 lines · Wang Xiaoming

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)

Quoted 4 lines

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?

I am not sure exactly which kernel introduced this Ngid. I check the git and found it added in
commit e29cf08b05dc0b8151d65704d96d525a9e179a6b And this change has destroyed the order already. Moving the adding option Ngid to the end of proc/PID/status is to keep order .

Quoted 2 lines

--
tejun

#3 lore raw

Hello,

Quoted 3 lines · Xiaoming

I am not sure exactly which kernel introduced this Ngid. I check the git and found it added in
commit e29cf08b05dc0b8151d65704d96d525a9e179a6b

git describe --contains says 3.13 and it's about 1.5 years ago.

Quoted 3 lines

And this change has destroyed the order already. Moving the adding option Ngid to the end of proc/PID/status is to keep order .

There isn't any assurance that changing the order won't break a different set of programs which make different ordering assumptions. The new order is already out there. This isn't a legal dispute where the original owner is "right".

Signature · 1 line
tejun
#4 lore raw

Dear tejun

Quoted 14 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tejun Heo
Sent: Friday, April 17, 2015 11:26 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Schallberger, Timothy M; Zhang, Dongxing
Subject: Re: [PATCH] proc: move the adding option Ngid to the end of proc/PID/status

Hello,

Quoted 8 lines
Quoted 3 lines · Xiaoming

I am not sure exactly which kernel introduced this Ngid. I check the git and found it added in
commit e29cf08b05dc0b8151d65704d96d525a9e179a6b

git describe --contains says 3.13 and it's about 1.5 years ago.

Yes this kernel change is 1.5 years ago.
As we known not all user update the kernel so frequently. They just use the stable one.
We met this issue when update to 3.13 now.
A lot of application failed to run which run well previously. Do you have any idea on this issue?

Quoted 11 lines
Quoted 3 lines

And this change has destroyed the order already.
Moving the adding option Ngid to the end of proc/PID/status is to keep order .

There isn't any assurance that changing the order won't break a different set of programs which make different ordering assumptions.
The new order is already out there. This isn't a legal dispute where the original owner is "right".

--
tejun

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#5 lore raw
Quoted 8 lines · Xiaoming
Quoted 2 lines

git describe --contains says 3.13 and it's about 1.5 years ago.

Yes this kernel change is 1.5 years ago.
As we known not all user update the kernel so frequently. They just use the stable one.
We met this issue when update to 3.13 now.
A lot of application failed to run which run well previously. Do you have any idea on this issue?

Not really. It's a sucky situation. How many applications are we talking about? I tried to find information on libsecuritysdk but couldn't find it anywhere.

Signature · 1 line
tejun
#6 lore raw

Dear tejun

Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tejun Heo
Sent: Friday, April 17, 2015 11:42 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Schallberger, Timothy M; Zhang, Dongxing
Subject: Re: [PATCH] proc: move the adding option Ngid to the end of proc/PID/status

Quoted 8 lines · Xiaoming
Quoted 2 lines

git describe --contains says 3.13 and it's about 1.5 years ago.

Yes this kernel change is 1.5 years ago.
As we known not all user update the kernel so frequently. They just use the stable one.
We met this issue when update to 3.13 now.
A lot of application failed to run which run well previously. Do you have any idea on this issue?

Quoted 3 lines

Not really. It's a sucky situation. How many applications are we talking about? I tried to find information on libsecuritysdk but couldn't find it anywhere.

This lib libsecuritysdk is included in application. Taobao, weibo, tmall, alipay, etc
It refer to security .

Quoted 2 lines

--
tejun

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#7 lore raw
Quoted 25 lines · Xiaoming

Dear tejun

Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tejun Heo
Sent: Friday, April 17, 2015 11:42 AM
To: Wang, Xiaoming
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Schallberger, Timothy M; Zhang, Dongxing
Subject: Re: [PATCH] proc: move the adding option Ngid to the end of proc/PID/status

Quoted 8 lines · Xiaoming
Quoted 2 lines

git describe --contains says 3.13 and it's about 1.5 years ago.

Yes this kernel change is 1.5 years ago.
As we known not all user update the kernel so frequently. They just use the stable one.
We met this issue when update to 3.13 now.
A lot of application failed to run which run well previously. Do you have any idea on this issue?

Quoted 6 lines
Quoted 3 lines

Not really. It's a sucky situation. How many applications are we talking about? I tried to find information on libsecuritysdk but couldn't find it anywhere.

This lib libsecuritysdk is included in application. Taobao, weibo, tmall, alipay, etc
It refer to security .

*cough* snake oil *cough*

Buggy non-robust code that is sold as providing a security function
deeply disturbs me. In this case libsecuritysdk is clearly buggy. The
point of labels at the beginning of lines is so that order is irrelevant.

If this had been reported by someone who cares enough to test any time during the 6 weeks of an rc series or even shortly after a stable
release we would have take this patch immediately. Because breaking
userspace is something we don't want to do, and it would have been clear what the trade-offs are.

In this case Tejun is right. We need to weigh the risk of fixing one application against the risk of breaking others. So far there has been no analysis about the possibility what other software might be affected by this change.

With respect to testing, linux is developed as a community and it is the responsibility for everyone in the community to pitch in and do what they can for the bits they care about.

As best as I can infer libsecuritysdk is doing it's best to ensure that a debugger is not attached while the library is being run. The code appears to be binary and proprietary. So the entire community of developers can not go out and read the code and see what is going on. This places a higher burden on those who develop and maintian libsecuritysdk to test and to verify their software will work with future versions of the linux kernel, and to more promptly bring issues to our attention.

In this instance until due dilligence has been done to indicate that making the change proposed will not result in another bug report in another 1.5 years from now about a different piece of software I am inclined to strongly suggest we do nothing.

Further is there any indication that even with this small change that the applications that use libsecuritysdk will work on 4.1-rc1 when it comes out in the next couple of days? Or even that those applications work on 4.0?

Eric