|
Message-ID: <tip-7f0a5e0755832301e7b010eab46fb715c483ba60@git.kernel.org> Date: Thu, 27 Jun 2019 15:18:10 -0700 From: tip-bot for Andy Lutomirski <tipbot@...or.com> To: linux-tip-commits@...r.kernel.org Cc: fweimer@...hat.com, jannh@...gle.com, peterz@...radead.org, hpa@...or.com, tglx@...utronix.de, bp@...en8.de, luto@...nel.org, kernel-hardening@...ts.openwall.com, linux-kernel@...r.kernel.org, mingo@...nel.org, keescook@...omium.org Subject: [tip:x86/entry] selftests/x86: Add a test for process_vm_readv() on the vsyscall page Commit-ID: 7f0a5e0755832301e7b010eab46fb715c483ba60 Gitweb: https://git.kernel.org/tip/7f0a5e0755832301e7b010eab46fb715c483ba60 Author: Andy Lutomirski <luto@...nel.org> AuthorDate: Wed, 26 Jun 2019 21:45:09 -0700 Committer: Thomas Gleixner <tglx@...utronix.de> CommitDate: Fri, 28 Jun 2019 00:04:40 +0200 selftests/x86: Add a test for process_vm_readv() on the vsyscall page get_gate_page() is a piece of somewhat alarming code to make get_user_pages() work on the vsyscall page. Test it via process_vm_readv(). Signed-off-by: Andy Lutomirski <luto@...nel.org> Signed-off-by: Thomas Gleixner <tglx@...utronix.de> Reviewed-by: Kees Cook <keescook@...omium.org> Cc: Florian Weimer <fweimer@...hat.com> Cc: Jann Horn <jannh@...gle.com> Cc: Borislav Petkov <bp@...en8.de> Cc: Kernel Hardening <kernel-hardening@...ts.openwall.com> Cc: Peter Zijlstra <peterz@...radead.org> Link: https://lkml.kernel.org/r/0fe34229a9330e8f9de9765967939cc4f1cf26b1.1561610354.git.luto@kernel.org --- tools/testing/selftests/x86/test_vsyscall.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c index 34a1d35995ef..4602326b8f5b 100644 --- a/tools/testing/selftests/x86/test_vsyscall.c +++ b/tools/testing/selftests/x86/test_vsyscall.c @@ -18,6 +18,7 @@ #include <sched.h> #include <stdbool.h> #include <setjmp.h> +#include <sys/uio.h> #ifdef __x86_64__ # define VSYS(x) (x) @@ -459,6 +460,38 @@ static int test_vsys_x(void) return 0; } +static int test_process_vm_readv(void) +{ +#ifdef __x86_64__ + char buf[4096]; + struct iovec local, remote; + int ret; + + printf("[RUN]\tprocess_vm_readv() from vsyscall page\n"); + + local.iov_base = buf; + local.iov_len = 4096; + remote.iov_base = (void *)0xffffffffff600000; + remote.iov_len = 4096; + ret = process_vm_readv(getpid(), &local, 1, &remote, 1, 0); + if (ret != 4096) { + printf("[OK]\tprocess_vm_readv() failed (ret = %d, errno = %d)\n", ret, errno); + return 0; + } + + if (vsyscall_map_r) { + if (!memcmp(buf, (const void *)0xffffffffff600000, 4096)) { + printf("[OK]\tIt worked and read correct data\n"); + } else { + printf("[FAIL]\tIt worked but returned incorrect data\n"); + return 1; + } + } +#endif + + return 0; +} + #ifdef __x86_64__ #define X86_EFLAGS_TF (1UL << 8) static volatile sig_atomic_t num_vsyscall_traps; @@ -533,6 +566,8 @@ int main(int argc, char **argv) nerrs += test_vsys_r(); nerrs += test_vsys_x(); + nerrs += test_process_vm_readv(); + #ifdef __x86_64__ nerrs += test_emulation(); #endif
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.