diff options
author | Kees Cook <[email protected]> | 2020-09-12 04:08:15 -0700 |
---|---|---|
committer | Kees Cook <[email protected]> | 2020-09-19 00:59:59 -0700 |
commit | e4e8e5d28d5e1dac24f775452d4cc6f49f5c069e (patch) | |
tree | d91403bc2a6da23a342525ed0b7af96198af8fcc | |
parent | dc2ad165f4fbef0fe1028b6b3720c5bec034874f (diff) |
selftests/seccomp: Avoid redundant register flushes
When none of the registers have changed, don't flush them back. This can
happen if the architecture uses a non-register way to change the syscall
(e.g. arm64) , and a return value hasn't been written.
Signed-off-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]
Acked-by: Christian Brauner <[email protected]>
-rw-r--r-- | tools/testing/selftests/seccomp/seccomp_bpf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 00056e067846..638cea8cb23d 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -1859,11 +1859,12 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee) void change_syscall(struct __test_metadata *_metadata, pid_t tracee, int syscall, int result) { - ARCH_REGS regs; + ARCH_REGS orig, regs; EXPECT_EQ(0, ARCH_GETREGS(regs)) { return; } + orig = regs; SYSCALL_NUM_SET(regs, syscall); @@ -1876,7 +1877,8 @@ void change_syscall(struct __test_metadata *_metadata, #endif /* Flush any register changes made. */ - EXPECT_EQ(0, ARCH_SETREGS(regs)); + if (memcmp(&orig, ®s, sizeof(orig)) != 0) + EXPECT_EQ(0, ARCH_SETREGS(regs)); } void tracer_seccomp(struct __test_metadata *_metadata, pid_t tracee, |