public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make sure to wake reaper
@ 2013-08-29 21:11 Serge Hallyn
  2013-08-29 22:08 ` Eric W. Biederman
  2013-08-30  0:39 ` Eric W. Biederman
  0 siblings, 2 replies; 16+ messages in thread
From: Serge Hallyn @ 2013-08-29 21:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: Eric W. Biederman, Oleg Nesterov


Since commit af4b8a83add95ef40716401395b44a1b579965f4 it's been
possible to get into a situation where a pidns reaper is
<defunct>, reparented to host pid 1, but never reaped.  How to
reproduce this is documented at

https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1168526
(and see
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1168526/comments/13)
In short, run repeated starts of a container whose init is

Process.exit(0);

sysrq-t when such a task is playing zombie shows:

[  131.132978] init            x ffff88011fc14580     0  2084   2039 0x00000000
[  131.132978]  ffff880116e89ea8 0000000000000002 ffff880116e89fd8 0000000000014580
[  131.132978]  ffff880116e89fd8 0000000000014580 ffff8801172a0000 ffff8801172a0000
[  131.132978]  ffff8801172a0630 ffff88011729fff0 ffff880116e14650 ffff88011729fff0
[  131.132978] Call Trace:
[  131.132978]  [<ffffffff816f6159>] schedule+0x29/0x70
[  131.132978]  [<ffffffff81064591>] do_exit+0x6e1/0xa40
[  131.132978]  [<ffffffff81071eae>] ? signal_wake_up_state+0x1e/0x30
[  131.132978]  [<ffffffff8106496f>] do_group_exit+0x3f/0xa0
[  131.132978]  [<ffffffff810649e4>] SyS_exit_group+0x14/0x20
[  131.132978]  [<ffffffff8170102f>] tracesys+0xe1/0xe6

Further debugging showed that every time this happened, zap_pid_ns_processes()
started with nr_hashed being 3, while we were expecting it to drop to 2.
Any time it didn't happen, nr_hashed was 1 or 2.  So the reaper was
waiting for nr_hashed to become 2, but free_pid() only wakes the reaper
if nr_hashed hits 1.  This patch makes free_pid() wake the reaper any
time the reaper is PF_EXITING, to force it to re-test the
pidns->nr_hashed = init_pids test.  Note that this is more like what
__unhash_process() used to do before
af4b8a83add95ef40716401395b44a1b579965f4.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
---
 kernel/pid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/pid.c b/kernel/pid.c
index 0db3e79..6b312c4 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -274,6 +274,10 @@ void free_pid(struct pid *pid)
 		case 0:
 			schedule_work(&ns->proc_work);
 			break;
+		default:
+			if (ns->child_reaper->flags & PF_EXITING)
+				wake_up_process(ns->child_reaper);
+			break;
 		}
 	}
 	spin_unlock_irqrestore(&pidmap_lock, flags);
-- 
1.8.3.2


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

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

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29 21:11 [PATCH] Make sure to wake reaper Serge Hallyn
2013-08-29 22:08 ` Eric W. Biederman
2013-08-30  0:39 ` Eric W. Biederman
2013-08-30  1:10   ` Serge E. Hallyn
2013-08-30  5:07     ` Eric W. Biederman
2013-08-30 12:46       ` Serge E. Hallyn
2013-08-30 14:42   ` Serge E. Hallyn
2013-08-31  0:30     ` [REVIEW][PATCH] pidns: Fix hang in zap_pid_ns_processes by sending a potentially extra wakeup Eric W. Biederman
2013-09-08 17:56       ` Oleg Nesterov
2013-09-08 18:01         ` free_pid() && PIDNS_HASH_ADDING Oleg Nesterov
2013-09-08 21:25           ` Eric W. Biederman
2013-09-09 15:15             ` Oleg Nesterov
2013-09-09 17:54               ` Eric W. Biederman
2013-09-10 14:01                 ` [PATCH 0/1] pidns: fix free_pid() to handle the first fork failure Oleg Nesterov
2013-09-10 14:01                   ` [PATCH 1/1] " Oleg Nesterov
     [not found]       ` <CALkWK0kSBrN-ZHG0CEWwvjYQ86ArJtDmbKqJR_6f3_ZTN6xJQQ@mail.gmail.com>
2013-09-09  0:12         ` [REVIEW][PATCH] pidns: Fix hang in zap_pid_ns_processes by sending a potentially extra wakeup Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox