lkml.org 
[lkml]   [2020]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/15] selftests/seccomp: Avoid redundant register flushes
Date
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 <keescook@chromium.org>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index d9346121b89b..2790d9cd50f4 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, &regs, sizeof(orig)) != 0)
+ EXPECT_EQ(0, ARCH_SETREGS(regs));
}

void tracer_seccomp(struct __test_metadata *_metadata, pid_t tracee,
--
2.25.1
\
 
 \ /
  Last update: 2020-09-12 13:10    [W:0.232 / U:1.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site