linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/pid.c: check pid whether be NULL in __change_pid()
@ 2013-10-07 10:29 Chen Gang
  2013-10-07 12:43 ` Oleg Nesterov
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Gang @ 2013-10-07 10:29 UTC (permalink / raw)
  To: Eric W. Biederman, Serge Hallyn, Oleg Nesterov, Serge E. Hallyn
  Cc: Andrew Morton, linux-kernel@vger.kernel.org

Within __change_pid(), 'new' may be NULL if it comes from detach_pid(),
and 'link->pid' also may be NULL ("link->pid = new"), so theoretically,\
the original 'link->pid' may be NULL, too.

In real world, at least now, all callers which will call detach_pid()
or change_pid() will not cause issue, but still recommend to check it
in __change_pid() to let itself consistency.

After the modification, it passed a simpe test: "build -> boot up ->
[s/g]et_[p/s/g]id() test by LTP tools".


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/pid.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index 9b9a266..15b1b3d 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -399,6 +399,9 @@ static void __change_pid(struct task_struct *task, enum pid_type type,
 	hlist_del_rcu(&link->node);
 	link->pid = new;
 
+	if (!pid)
+		return;
+
 	for (tmp = PIDTYPE_MAX; --tmp >= 0; )
 		if (!hlist_empty(&pid->tasks[tmp]))
 			return;
-- 
1.7.7.6

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

end of thread, other threads:[~2013-10-09  1:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-07 10:29 [PATCH] kernel/pid.c: check pid whether be NULL in __change_pid() Chen Gang
2013-10-07 12:43 ` Oleg Nesterov
2013-10-07 21:53   ` Chen Gang
2013-10-08 17:56     ` Oleg Nesterov
2013-10-09  1:03       ` Chen Gang

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