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

tools/testing/selftests/proc/proc-pid-vm.c: hide "segfault at ffffffffff600000" dmesg spam

Test tries to access vsyscall page and if it doesn't exist gets SIGSEGV
which can spam into dmesg. However the segfault happens by design.
Handle it and carry information via exit code to parent.

Link: http://lkml.kernel.org/r/20190524181256.GA2260@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
bca1eac5 9b98fa22

+15 -2
+15 -2
tools/testing/selftests/proc/proc-pid-vm.c
··· 215 215 "ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n"; 216 216 217 217 #ifdef __x86_64__ 218 + static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___) 219 + { 220 + _exit(1); 221 + } 222 + 218 223 /* 219 224 * vsyscall page can't be unmapped, probe it with memory load. 220 225 */ ··· 236 231 if (pid == 0) { 237 232 struct rlimit rlim = {0, 0}; 238 233 (void)setrlimit(RLIMIT_CORE, &rlim); 234 + 235 + /* Hide "segfault at ffffffffff600000" messages. */ 236 + struct sigaction act; 237 + memset(&act, 0, sizeof(struct sigaction)); 238 + act.sa_flags = SA_SIGINFO; 239 + act.sa_sigaction = sigaction_SIGSEGV; 240 + (void)sigaction(SIGSEGV, &act, NULL); 241 + 239 242 *(volatile int *)0xffffffffff600000UL; 240 243 exit(0); 241 244 } 242 - wait(&wstatus); 243 - if (WIFEXITED(wstatus)) { 245 + waitpid(pid, &wstatus, 0); 246 + if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) { 244 247 g_vsyscall = true; 245 248 } 246 249 }