Skip to contentSkip to conversation

Add regression tests for vsyscall and vdso

PATCH Superseded [email protected] 2 participants 2 messages Aug 3, 2017 – Aug 9, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add regression tests for vsyscall and vdso

From: Veronika Kabatova <[email protected]>

Test checks if vsyscall and vdso VMAs are reported correctly. vsyscall range and permissions were fixed with kernel commit 103efcd9aac1 ("fix perms/range of vsyscall vma in /proc/*/maps"). While some newer systems run with CONFIG_LEGACY_VSYSCALL_NONE, this test may serve to find regressions on systems still running with vsyscalls.

Second part of the test checks regression of vdso permissions bug (fixed with b6558c4a2378 ("fix [vdso] page permissions") and e5b97dde514f ("add VM_ALWAYSDUMP")). As a consequence of this bug, vdso pages were not included in core dumps which caused incomplete backtraces:

    Program terminated with signal 11, Segmentation fault.
    #0  0x005f0402 in ?? ()

    Thread 1 (process 14859):
    #0  0x005f0402 in ?? ()
    #1  0x00336366 in ?? () from /lib/i686/nosegneg/libc.so.6
    #2  0x0804845f in handle_alrm (signo=14) at small.c:9
    #3  0x005f0420 in ?? ()
    #4  0x0000000e in ?? ()
    #5  0x00000033 in ?? ()
    #6  0x00000000 in ?? ()
---
 runtest/mm                            |  1 +
 testcases/kernel/mem/.gitignore       |  1 +
 testcases/kernel/mem/vma/Makefile     |  2 +
 testcases/kernel/mem/vma/vma05.sh     | 80 +++++++++++++++++++++++++++++++++++
 testcases/kernel/mem/vma/vma05_vdso.c |  7 +++
 5 files changed, 91 insertions(+)
 create mode 100755 testcases/kernel/mem/vma/vma05.sh
 create mode 100644 testcases/kernel/mem/vma/vma05_vdso.c
runtest/mm +1 -0
index d108d1897..55fc2cab0 100644
@@ -89,6 +89,7 @@ vma01 vma01
 vma02 vma02
 vma03 vma03
 vma04 vma04
+vma05 vma05.sh
 
 overcommit_memory01 overcommit_memory
 overcommit_memory02 overcommit_memory -R 0
testcases/kernel/mem/.gitignore +1 -0
index 51701190a..ce21ca70f 100644
@@ -72,5 +72,6 @@
 /vma/vma02
 /vma/vma03
 /vma/vma04
+/vma/vma05_vdso
 /vmtests/data_space
 /vmtests/stack_space
testcases/kernel/mem/vma/Makefile +2 -0
index b323dbfd5..966148cbd 100644
@@ -19,6 +19,8 @@
 
 top_srcdir              ?= ../../../..
 
+vma05_vdso: CFLAGS+=-ggdb3
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/vma/vma05.sh new file +80 -0

80 lines not on this page · raw message

testcases/kernel/mem/vma/vma05_vdso.c new file +7 -0
new file mode 100644
index 000000000..507de50d5
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int main(void)
+{
+	raise(SIGSEGV);
+	return 0;
+}
Signature · 1 line
2.13.3
#1 lore raw

PATCH v2 1/1 Add regression tests for vsyscall and vdso

Hi!

Quoted 7 lines
testcases/kernel/mem/vma/vma05.sh new file +7 -0
+vma_report_check()
+{
+	if [ $(uname -m) == "x86_64" ] ; then
+		if LINE=$(grep "vsyscall" /proc/self/maps) ; then
+			RIGHT="ffffffffff600000-ffffffffff601000[[:space:]]r-xp"
+			if grep -q "$RIGHT" <<< "$LINE" ; then
+				tst_res TPASS "[vsyscall] reported correctly"

testcases/kernel/mem/vma/vma05.sh line 72

Quoted 10 lines
testcases/kernel/mem/vma/vma05.sh new file +10 -0
+			else
+				tst_res TFAIL "[vsyscall] reporting wrong"
+			fi
+		fi
+	fi
+
+	rm -rf core*
+	{ vma05_vdso; } >& /dev/null
+	TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
+		vma05_vdso ./core* 2> /dev/null)

One last nit, we should make sure that /proc/sys/kernel/core_pattern is set to 'core' otherwise this may fail to find the core file.

We can set and reset it in the setup/cleanup as we do with the ulimit if it's present.

Signature · 2 lines
Cyril Hrubis
[email protected]