[RFC PATCH] 2.6.22.6 user-mode linux: before abort, we make it sure all children quit

Previous thread: 2.6.22.6 + oprofile oops by Sami Farin on Saturday, September 22, 2007 - 7:23 am. (7 messages)

Next thread: Unfortunate infinite make recursion by Jan Engelhardt on Saturday, September 22, 2007 - 7:24 am. (8 messages)
To: <jdike@...>
Cc: lkm <linux-kernel@...>
Date: Saturday, September 22, 2007 - 4:01 am

In a stock 2.6.22.6 kernel, poweroff a user mode linux guest
(2.6.22.6 running in skas0 mode) will halt the host linux. I
think the reason is the kernel thread abort because of a bug.
Then the sys_reboot in process of user mode linux guest is
not trapped by the user mode linux kernel and is executed by host.
I think it is better to make sure all of our children process
to quit when user mode linux kernel abort.

Signed-off-by: Lepton Wu <ytht.net@gmail.com>

diff -X linux-2.6.22.6/Documentation/dontdiff -pru linux-2.6.22.6/arch/um/os-Linux/util.c linux-2.6.22.6-lepton/arch/um/os-Linux/util.c
--- linux-2.6.22.6/arch/um/os-Linux/util.c 2007-09-14 17:41:10.000000000 +0800
+++ linux-2.6.22.6-lepton/arch/um/os-Linux/util.c 2007-09-22 13:56:05.000000000 +0800
@@ -106,5 +106,6 @@ int setjmp_wrapper(void (*proc)(void *,
void os_dump_core(void)
{
signal(SIGSEGV, SIG_DFL);
+ kill(0, SIGTERM);
abort();
}
-

To: lepton <ytht.net@...>
Cc: lkm <linux-kernel@...>
Date: Tuesday, September 25, 2007 - 1:53 pm

Below is what I currently have for this patch. As you sent it in, the
kill(0, SIGTERM) would immediately kill the kernel process along with
everything else, before it can dump core. So, I have the kernel
ignore SIGTERM.

Then, there are still processes which survive. The one case I think I
understand is that a process is handling an infinite sequence of
SIGSEGVs and never sees the SIGTERM. So, I added a loop which waits
for all of the current child processes and kills each one as it
returns some sort of status.

Jeff

--
Work email - jdike at linux dot intel dot com

From: Lepton Wu <ytht.net@gmail.com>

In a stock 2.6.22.6 kernel, poweroff a user mode linux guest
(2.6.22.6 running in skas0 mode) will halt the host linux. I
think the reason is the kernel thread abort because of a bug.
Then the sys_reboot in process of user mode linux guest is
not trapped by the user mode linux kernel and is executed by host.
I think it is better to make sure all of our children process
to quit when user mode linux kernel abort.

[ jdike - the kernel process needs to ignore SIGTERM, plus the
waitpid/kill loop is needed to make sure that all of our children
are dead before the kernel exits ]

Signed-off-by: Lepton Wu <ytht.net@gmail.com>
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
---
arch/um/os-Linux/skas/process.c | 2 +-
arch/um/os-Linux/util.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)

Index: linux-2.6.22/arch/um/os-Linux/util.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/util.c 2007-09-25 13:33:48.000000000 -0400
+++ linux-2.6.22/arch/um/os-Linux/util.c 2007-09-25 13:45:33.000000000 -0400
@@ -105,6 +105,44 @@ int setjmp_wrapper(void (*proc)(void *,

void os_dump_core(void)
{
+ int pid;
+
signal(SIGSEGV, SIG_DFL);
+
+ /*
+ * We are about to SIGTERM this entire process group to ensure that
+ * nothing i...

Previous thread: 2.6.22.6 + oprofile oops by Sami Farin on Saturday, September 22, 2007 - 7:23 am. (7 messages)

Next thread: Unfortunate infinite make recursion by Jan Engelhardt on Saturday, September 22, 2007 - 7:24 am. (8 messages)