From: Andy Lutomirski <luto@kernel.org>
To: x86@kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Kees Cook <keescook@chromium.org>,
Florian Weimer <fweimer@redhat.com>, Jann Horn <jannh@google.com>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Kernel Hardening <kernel-hardening@lists.openwall.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH v2 8/8] selftests/x86: Add a test for process_vm_readv() on the vsyscall page
Date: Wed, 26 Jun 2019 21:45:09 -0700 [thread overview]
Message-ID: <0fe34229a9330e8f9de9765967939cc4f1cf26b1.1561610354.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1561610354.git.luto@kernel.org>
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().
Cc: Kees Cook <keescook@chromium.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Kernel Hardening <kernel-hardening@lists.openwall.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andy Lutomirski <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
--
2.21.0
next prev parent reply other threads:[~2019-06-27 4:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-27 4:45 [PATCH v2 0/8] vsyscall xonly mode Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 1/8] x86/vsyscall: Remove the vsyscall=native documentation Andy Lutomirski
2019-06-27 17:26 ` Kees Cook
2019-06-27 22:13 ` [tip:x86/entry] Documentation/admin: " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 2/8] x86/vsyscall: Add a new vsyscall=xonly mode Andy Lutomirski
2019-06-27 17:26 ` Kees Cook
2019-06-27 22:13 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 3/8] x86/vsyscall: Show something useful on a read fault Andy Lutomirski
2019-06-27 17:28 ` Kees Cook
2019-06-27 22:14 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 4/8] x86/vsyscall: Document odd SIGSEGV error code for vsyscalls Andy Lutomirski
2019-06-27 17:28 ` Kees Cook
2019-06-27 22:15 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 5/8] selftests/x86/vsyscall: Verify that vsyscall=none blocks execution Andy Lutomirski
2019-06-27 17:29 ` Kees Cook
2019-06-27 22:16 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 6/8] x86/vsyscall: Change the default vsyscall mode to xonly Andy Lutomirski
2019-06-27 17:30 ` Kees Cook
2019-06-27 22:16 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` [PATCH v2 7/8] x86/vsyscall: Add __ro_after_init to global variables Andy Lutomirski
2019-06-27 17:30 ` Kees Cook
2019-06-27 22:17 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
2019-06-27 4:45 ` Andy Lutomirski [this message]
2019-06-27 17:30 ` [PATCH v2 8/8] selftests/x86: Add a test for process_vm_readv() on the vsyscall page Kees Cook
2019-06-27 22:18 ` [tip:x86/entry] " tip-bot for Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0fe34229a9330e8f9de9765967939cc4f1cf26b1.1561610354.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=bp@alien8.de \
--cc=fweimer@redhat.com \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).