selftests/x86/ptrace_syscall_32: Fix no-vDSO segfault
authorAndy Lutomirski <luto@kernel.org>
Thu, 12 Mar 2020 22:35:51 +0000 (15:35 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 06:00:27 +0000 (08:00 +0200)
[ Upstream commit 630b99ab60aa972052a4202a1ff96c7e45eb0054 ]

If AT_SYSINFO is not present, don't try to call a NULL pointer.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/faaf688265a7e1a5b944d6f8bc0f6368158306d3.1584052409.git.luto@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/x86/ptrace_syscall.c

index 6f22238f32173db4ef4d710666807cb5397f7dc0..12aaa063196e7406a08188a64570d46ce407ec91 100644 (file)
@@ -414,8 +414,12 @@ int main()
 
 #if defined(__i386__) && (!defined(__GLIBC__) || __GLIBC__ > 2 || __GLIBC_MINOR__ >= 16)
        vsyscall32 = (void *)getauxval(AT_SYSINFO);
-       printf("[RUN]\tCheck AT_SYSINFO return regs\n");
-       test_sys32_regs(do_full_vsyscall32);
+       if (vsyscall32) {
+               printf("[RUN]\tCheck AT_SYSINFO return regs\n");
+               test_sys32_regs(do_full_vsyscall32);
+       } else {
+               printf("[SKIP]\tAT_SYSINFO is not available\n");
+       }
 #endif
 
        test_ptrace_syscall_restart();