Commit e4e8e5d2 authored by Kees Cook's avatar Kees Cook

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: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/lkml/20200912110820.597135-11-keescook@chromium.orgAcked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
parent dc2ad165
...@@ -1859,11 +1859,12 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee) ...@@ -1859,11 +1859,12 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
void change_syscall(struct __test_metadata *_metadata, void change_syscall(struct __test_metadata *_metadata,
pid_t tracee, int syscall, int result) pid_t tracee, int syscall, int result)
{ {
ARCH_REGS regs; ARCH_REGS orig, regs;
EXPECT_EQ(0, ARCH_GETREGS(regs)) { EXPECT_EQ(0, ARCH_GETREGS(regs)) {
return; return;
} }
orig = regs;
SYSCALL_NUM_SET(regs, syscall); SYSCALL_NUM_SET(regs, syscall);
...@@ -1876,7 +1877,8 @@ void change_syscall(struct __test_metadata *_metadata, ...@@ -1876,7 +1877,8 @@ void change_syscall(struct __test_metadata *_metadata,
#endif #endif
/* Flush any register changes made. */ /* 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, void tracer_seccomp(struct __test_metadata *_metadata, pid_t tracee,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment