aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2019-07-16 19:26:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-16 22:23:21 -0400
commitbca1eac55a940025065645158c1a3429ac697df6 (patch)
treef2c75adba5307ec99773064f8ca7a078a22bc748
parent9b98fa22948551e20a15b0b9d22589e3724c361a (diff)
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>
-rw-r--r--tools/testing/selftests/proc/proc-pid-vm.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index 853aa164a401..18a3bde8bc96 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -215,6 +215,11 @@ static const char str_vsyscall[] =
215"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n"; 215"ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n";
216 216
217#ifdef __x86_64__ 217#ifdef __x86_64__
218static void sigaction_SIGSEGV(int _, siginfo_t *__, void *___)
219{
220 _exit(1);
221}
222
218/* 223/*
219 * vsyscall page can't be unmapped, probe it with memory load. 224 * vsyscall page can't be unmapped, probe it with memory load.
220 */ 225 */
@@ -231,11 +236,19 @@ static void vsyscall(void)
231 if (pid == 0) { 236 if (pid == 0) {
232 struct rlimit rlim = {0, 0}; 237 struct rlimit rlim = {0, 0};
233 (void)setrlimit(RLIMIT_CORE, &rlim); 238 (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
234 *(volatile int *)0xffffffffff600000UL; 247 *(volatile int *)0xffffffffff600000UL;
235 exit(0); 248 exit(0);
236 } 249 }
237 wait(&wstatus); 250 waitpid(pid, &wstatus, 0);
238 if (WIFEXITED(wstatus)) { 251 if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0) {
239 g_vsyscall = true; 252 g_vsyscall = true;
240 } 253 }
241} 254}