From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Cedric Le Goater <clg@fr.ibm.com>,
Dave Hansen <haveblue@us.ibm.com>,
Eric Biederman <ebiederm@xmission.com>,
Herbert Poetzl <herbert@13thfloor.at>,
Ingo Molnar <mingo@elte.hu>,
Mathias Krause <Mathias.Krause@secunet.com>,
Roland McGrath <roland@redhat.com>,
Serge Hallyn <serue@us.ibm.com>,
Sukadev Bhattiprolu <sukadev@us.ibm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] pids: init_struct_pid.tasks should never see the swapper process
Date: Mon, 10 May 2010 21:50:14 +0200 [thread overview]
Message-ID: <20100510195014.GC5249@redhat.com> (raw)
In-Reply-To: <20100510194917.GA5249@redhat.com>
"statically initialize struct pid for swapper" commit 820e45db says:
Statically initialize a struct pid for the swapper process (pid_t == 0)
and attach it to init_task. This is needed so task_pid(), task_pgrp()
and task_session() interfaces work on the swapper process also.
OK, but:
- it doesn't make sense to add init_task.pids[].node into
init_struct_pid.tasks[], and in fact this just wrong.
idle threads are special, they shouldn't be visible on any
global list. In particular do_each_pid_task(init_struct_pid)
shouldn't see swapper.
This is the actual reason why kill(0, SIGKILL) from /sbin/init
(which starts with 0,0 special pids) crashes the kernel. The
signal sent to pgid/sid == 0 must never see idle threads, even
if the previous patch fixed the crash itself.
- we have other idle threads running on the non-boot CPUs, see
the next patch.
Change INIT_STRUCT_PID/INIT_PID_LINK to create the empty/unhashed
hlist_head/hlist_node. Like any other idle thread swapper can never exit,
so detach_pid()->__hlist_del() is not possible, but we could change
INIT_PID_LINK() to set pprev = &next if needed.
All we need is the valid swapper->pids[].pid == &init_struct_pid.
Reported-by: Mathias Krause <mathias.krause@secunet.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/init_task.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- 34-rc1/include/linux/init_task.h~2_INIT_PID_DONT_LINK_SWAPPER 2010-05-10 19:45:27.000000000 +0200
+++ 34-rc1/include/linux/init_task.h 2010-05-10 20:26:08.000000000 +0200
@@ -53,9 +53,9 @@ extern struct group_info init_groups;
#define INIT_STRUCT_PID { \
.count = ATOMIC_INIT(1), \
.tasks = { \
- { .first = &init_task.pids[PIDTYPE_PID].node }, \
- { .first = &init_task.pids[PIDTYPE_PGID].node }, \
- { .first = &init_task.pids[PIDTYPE_SID].node }, \
+ { .first = NULL }, \
+ { .first = NULL }, \
+ { .first = NULL }, \
}, \
.rcu = RCU_HEAD_INIT, \
.level = 0, \
@@ -70,7 +70,7 @@ extern struct group_info init_groups;
{ \
.node = { \
.next = NULL, \
- .pprev = &init_struct_pid.tasks[type].first, \
+ .pprev = NULL, \
}, \
.pid = &init_struct_pid, \
}
next prev parent reply other threads:[~2010-05-10 19:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4BE01C86.3050908@secunet.com>
2010-05-09 18:45 ` kernel panic on kill(0, SIGTERM) with PGID == 0 Oleg Nesterov
2010-05-09 19:06 ` Oleg Nesterov
2010-05-10 7:20 ` Mathias Krause
2010-05-10 19:49 ` [PATCH 0/4] swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0) Oleg Nesterov
2010-05-10 19:49 ` [PATCH 1/4] INIT_TASK() should initialize ->thread_group list Oleg Nesterov
2010-05-11 7:52 ` Serge E. Hallyn
2010-05-12 2:15 ` Sukadev Bhattiprolu
2010-05-12 15:54 ` Oleg Nesterov
2010-05-10 19:50 ` Oleg Nesterov [this message]
2010-05-11 9:54 ` [PATCH 2/4] pids: init_struct_pid.tasks should never see the swapper process Serge E. Hallyn
2010-05-12 16:03 ` Oleg Nesterov
2010-05-10 19:50 ` [PATCH 3/4] pids: fix fork_idle() to setup ->pids correctly Oleg Nesterov
2010-05-11 8:54 ` Serge E. Hallyn
2010-05-10 19:51 ` [PATCH 4/4] INIT_SIGHAND: use SIG_DFL instead of NULL Oleg Nesterov
2010-05-11 8:54 ` Serge E. Hallyn
2010-05-10 21:08 ` [PATCH 0/4] swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0) Andrew Morton
2010-05-10 21:41 ` Oleg Nesterov
2010-05-10 23:55 ` Roland McGrath
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=20100510195014.GC5249@redhat.com \
--to=oleg@redhat.com \
--cc=Mathias.Krause@secunet.com \
--cc=akpm@linux-foundation.org \
--cc=clg@fr.ibm.com \
--cc=ebiederm@xmission.com \
--cc=haveblue@us.ibm.com \
--cc=herbert@13thfloor.at \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=serue@us.ibm.com \
--cc=sukadev@us.ibm.com \
/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).