From: Richard Weinberger <richard@nod.at>
To: linux-kernel@vger.kernel.org
Cc: Richard Weinberger <richard@nod.at>,
user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] [PATCH 2/4] um: fix abort
Date: Sun, 8 May 2011 23:59:43 +0200 [thread overview]
Message-ID: <1304891985-11569-2-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1304891985-11569-1-git-send-email-richard@nod.at>
os_dump_core() uses abort() to terminate UML in case of an
fatal error.
glibc's abort() calls raise(SIGABRT) which makes use of tgkill().
tgkill() has no effect within UML's kernel threads because they
are not pthreads. As fallback abort() executes an invalid instruction
to terminate the process. Therefore UML gets killed by SIGSEGV and
leaves a ugly log entry in the host's kernel ring buffer.
To get rid of this use our own abort routine.
# Untracked files:
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/um/os-Linux/util.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c
index 6ea7797..42827ca 100644
--- a/arch/um/os-Linux/util.c
+++ b/arch/um/os-Linux/util.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
@@ -75,6 +76,26 @@ void setup_hostinfo(char *buf, int len)
host.release, host.version, host.machine);
}
+/*
+ * We cannot use glibc's abort(). It makes use of tgkill() which
+ * has no effect within UML's kernel threads.
+ * After that glibc would execute an invalid instruction to kill
+ * the calling process and UML crashes with SIGSEGV.
+ */
+static inline void __attribute__ ((noreturn)) uml_abort(void)
+{
+ sigset_t sig;
+
+ fflush(NULL);
+
+ if (!sigemptyset(&sig) && !sigaddset(&sig, SIGABRT))
+ sigprocmask(SIG_UNBLOCK, &sig, 0);
+
+ for (;;)
+ if (kill(getpid(), SIGABRT) < 0)
+ exit(127);
+}
+
void os_dump_core(void)
{
int pid;
@@ -116,5 +137,5 @@ void os_dump_core(void)
while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0)
os_kill_ptraced_process(pid, 0);
- abort();
+ uml_abort();
}
--
1.7.4.2
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2011-05-08 22:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-08 21:59 [uml-devel] [PATCH 1/4] um: fix UML_LIB_PATH Richard Weinberger
2011-05-08 21:59 ` Richard Weinberger [this message]
2011-05-08 21:59 ` [PATCH 3/4] um: remove SIGHUP handler Richard Weinberger
2011-05-08 21:59 ` [PATCH 4/4] um: os_dump_core() cleanup Richard Weinberger
2011-05-08 22:19 ` [uml-devel] [PATCH 1/4] um: fix UML_LIB_PATH Mattia Dongili
2011-05-08 22:24 ` Richard Weinberger
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=1304891985-11569-2-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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