Skip to contentSkip to conversation

x86/asm/entry/32, selftests: Add test_syscall_vdso test

PATCH Superseded Denys Vlasenko 2 participants 5 messages Jun 12, 2015 – Jun 15, 2015

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/asm/entry/32, selftests: Add test_syscall_vdso test

The test is fairly simplistic: it checks that all registers are preserved across 32-bit syscall via VDSO.

Run-tested:

$ ./test_syscall_vdso_32
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
[RUN]	Running tests under ptrace
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
CC Linus Torvalds <[email protected]>
CC Steven Rostedt <[email protected]>
CC Ingo Molnar <[email protected]>
CC Borislav Petkov <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andy Lutomirski <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Alexei Starovoitov <[email protected]>
CC Will Drewry <[email protected]>
CC Kees Cook <[email protected]>

---
Changes in v2:
does not fail if VDSO can't be found;
tests INT 80 syscall method;
tests syscalls under ptrace;
switched to /* */ comments

 tools/testing/selftests/x86/Makefile            |   2 +-
 tools/testing/selftests/x86/test_syscall_vdso.c | 271 ++++++++++++++++++++++++
 2 files changed, 272 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/x86/test_syscall_vdso.c
tools/testing/selftests/x86/Makefile +1 -1
index caa60d5..84effa6 100644
@@ -5,7 +5,7 @@ include ../lib.mk
 .PHONY: all all_32 all_64 warn_32bit_failure clean
 
 TARGETS_C_BOTHBITS := sigreturn single_step_syscall sysret_ss_attrs
-TARGETS_C_32BIT_ONLY := entry_from_vm86
+TARGETS_C_32BIT_ONLY := entry_from_vm86 test_syscall_vdso
 
 TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY)
 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
tools/testing/selftests/x86/test_syscall_vdso.c new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw

tools/testing/selftests/x86/test_syscall_vdso.c line 270

Quoted 6 lines · Denys Vlasenko
tools/testing/selftests/x86/test_syscall_vdso.c new file +6 -0
+	exitcode += run_syscall_twice();
+	ptrace_me();
+	exitcode += run_syscall_twice();
+
+	return 0;
+}

Er... that last line was supposed to be "return exitcode;"

#2 lore raw
In reply to Denys Vlasenko
Quoted 5 lines · Denys Vlasenko

The test is fairly simplistic: it checks that all registers are preserved across 32-bit syscall via VDSO.

Run-tested:

Quoted 10 lines
$ ./test_syscall_vdso_32
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
[RUN]	Running tests under ptrace
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall

Just curious: is there a kernel sha1 where this test would fail? Or did you try to provoke an information leak perhaps?

Thanks,

Ingo

#3 lore raw
Quoted 19 lines · Ingo Molnar
Quoted 5 lines · Denys Vlasenko

The test is fairly simplistic: it checks that all registers are preserved across 32-bit syscall via VDSO.

Run-tested:

Quoted 10 lines
$ ./test_syscall_vdso_32
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
[RUN]	Running tests under ptrace
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
Quoted 2 lines

Just curious: is there a kernel sha1 where this test would fail? Or did you try to provoke an information leak perhaps?

I did see failures, more than once, when testing my own patches.

I'm not aware of released kernels which are buggy wrt this test.

#4 lore raw
Quoted 20 lines · Denys Vlasenko
Quoted 19 lines · Ingo Molnar
Quoted 15 lines · Denys Vlasenko

The test is fairly simplistic: it checks that all registers are preserved across 32-bit syscall via VDSO.

Run-tested:

$ ./test_syscall_vdso_32
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
[RUN]	Running tests under ptrace
[RUN]	Executing 6-argument 32-bit syscall via VDSO
[Ok]	Arguments are preserved across syscall
[RUN]	Executing 6-argument 32-bit syscall via INT 80
[Ok]	Arguments are preserved across syscall
Quoted 4 lines
Quoted 2 lines

Just curious: is there a kernel sha1 where this test would fail? Or did you try to provoke an information leak perhaps?

I did see failures, more than once, when testing my own patches.

Ok!

Quoted 1 line

I'm not aware of released kernels which are buggy wrt this test.

Great! :-)

Thanks,

Ingo