Skip to content

Commit bca1eac

Browse files
Alexey Dobriyantorvalds
authored andcommitted
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>
1 parent 9b98fa2 commit bca1eac

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎tools/testing/selftests/proc/proc-pid-vm.c‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ static const char str_vsyscall[] =
215215
"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n";
216216

217217
#ifdef __x86_64__
218+
static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___)
219+
{
220+
_exit(1);
221+
}
222+
218223
/*
219224
* vsyscall page can't be unmapped, probe it with memory load.
220225
*/
@@ -231,11 +236,19 @@ static void vsyscall(void)
231236
if (pid == 0) {
232237
struct rlimit rlim = {0, 0};
233238
(void)setrlimit(RLIMIT_CORE, &rlim);
239+
240+
/* Hide "segfault at ffffffffff600000" messages. */
241+
struct sigaction act;
242+
memset(&act, 0, sizeof(struct sigaction));
243+
act.sa_flags = SA_SIGINFO;
244+
act.sa_sigaction = sigaction_SIGSEGV;
245+
(void)sigaction(SIGSEGV, &act, NULL);
246+
234247
*(volatile int *)0xffffffffff600000UL;
235248
exit(0);
236249
}
237-
wait(&wstatus);
238-
if (WIFEXITED(wstatus)) {
250+
waitpid(pid, &wstatus, 0);
251+
if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) {
239252
g_vsyscall = true;
240253
}
241254
}

0 commit comments

Comments
 (0)