Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

um: fix abort

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 we use our own abort routine.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Richard Weinberger and committed by
Linus Torvalds
b2db2199 d6c438b6

+22 -1
+22 -1
arch/um/os-Linux/util.c
··· 5 5 6 6 #include <stdio.h> 7 7 #include <stdlib.h> 8 + #include <unistd.h> 8 9 #include <errno.h> 9 10 #include <signal.h> 10 11 #include <string.h> ··· 76 75 host.release, host.version, host.machine); 77 76 } 78 77 78 + /* 79 + * We cannot use glibc's abort(). It makes use of tgkill() which 80 + * has no effect within UML's kernel threads. 81 + * After that glibc would execute an invalid instruction to kill 82 + * the calling process and UML crashes with SIGSEGV. 83 + */ 84 + static inline void __attribute__ ((noreturn)) uml_abort(void) 85 + { 86 + sigset_t sig; 87 + 88 + fflush(NULL); 89 + 90 + if (!sigemptyset(&sig) && !sigaddset(&sig, SIGABRT)) 91 + sigprocmask(SIG_UNBLOCK, &sig, 0); 92 + 93 + for (;;) 94 + if (kill(getpid(), SIGABRT) < 0) 95 + exit(127); 96 + } 97 + 79 98 void os_dump_core(void) 80 99 { 81 100 int pid; ··· 137 116 while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0) 138 117 os_kill_ptraced_process(pid, 0); 139 118 140 - abort(); 119 + uml_abort(); 141 120 }