Skip to content

Commit

Permalink
tools/testing/selftests/proc/proc-pid-vm.c: hide "segfault at fffffff…
Browse files Browse the repository at this point in the history
…fff600000" 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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed Jul 17, 2019
1 parent 9b98fa2 commit bca1eac
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tools/testing/selftests/proc/proc-pid-vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ static const char str_vsyscall[] =
"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n";

#ifdef __x86_64__
static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___)
{
_exit(1);
}

/*
* vsyscall page can't be unmapped, probe it with memory load.
*/
Expand All @@ -231,11 +236,19 @@ static void vsyscall(void)
if (pid == 0) {
struct rlimit rlim = {0, 0};
(void)setrlimit(RLIMIT_CORE, &rlim);

/* Hide "segfault at ffffffffff600000" messages. */
struct sigaction act;
memset(&act, 0, sizeof(struct sigaction));
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = sigaction_SIGSEGV;
(void)sigaction(SIGSEGV, &act, NULL);

*(volatile int *)0xffffffffff600000UL;
exit(0);
}
wait(&wstatus);
if (WIFEXITED(wstatus)) {
waitpid(pid, &wstatus, 0);
if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) {
g_vsyscall = true;
}
}
Expand Down

0 comments on commit bca1eac

Please sign in to comment.