From: =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=@zytor.com
To: =?UTF-8?B?bGludXgtdGlwLWNvbW1pdHNAdmdlci5rZXJuZWwub3Jn?=@zytor.com
Cc: luto@amacapital.net, david.brown@linaro.org, mpe@ellerman.id.au,
keescook@chromium.org, hpa@linux.intel.com,
linux-arch@vger.kernel.org, bp@alien8.de,
linux-kernel@vger.kernel.org, luto@kernel.org,
spender@grsecurity.net, dvlasenk@redhat.com, mingo@kernel.org,
pageexec@freemail.hu, tglx@linutronix.de, hpa@zytor.com,
minipli@googlemail.com, torvalds@linux-foundation.org,
peterz@infradead.org, arnd@arndb.de, brgerst@gmail.com,
re.emese@gmail.com
Subject: [tip:mm/readonly] x86/vdso: Mark the vDSO code read-only after init
Date: Mon, 22 Feb 2016 04:20:21 -0800 [thread overview]
Message-ID: <tip-018ef8dcf3de5f62e2cc1a9273cc27e1c6ba8de5@git.kernel.org> (raw)
In-Reply-To: <1455748879-21872-7-git-send-email-keescook@chromium.org>
Commit-ID: 018ef8dcf3de5f62e2cc1a9273cc27e1c6ba8de5
Gitweb: http://git.kernel.org/tip/018ef8dcf3de5f62e2cc1a9273cc27e1c6ba8de5
Author: Kees Cook <keescook@chromium.org>
AuthorDate: Wed, 17 Feb 2016 14:41:17 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 22 Feb 2016 08:51:39 +0100
x86/vdso: Mark the vDSO code read-only after init
The vDSO does not need to be writable after __init, so mark it as
__ro_after_init. The result kills the exploit method of writing to the
vDSO from kernel space resulting in userspace executing the modified code,
as shown here to bypass SMEP restrictions: http://itszn.com/blog/?p=21
The memory map (with added vDSO address reporting) shows the vDSO moving
into read-only memory:
Before:
[ 0.143067] vDSO @ ffffffff82004000
[ 0.143551] vDSO @ ffffffff82006000
---[ High Kernel Mapping ]---
0xffffffff80000000-0xffffffff81000000 16M pmd
0xffffffff81000000-0xffffffff81800000 8M ro PSE GLB x pmd
0xffffffff81800000-0xffffffff819f3000 1996K ro GLB x pte
0xffffffff819f3000-0xffffffff81a00000 52K ro NX pte
0xffffffff81a00000-0xffffffff81e00000 4M ro PSE GLB NX pmd
0xffffffff81e00000-0xffffffff81e05000 20K ro GLB NX pte
0xffffffff81e05000-0xffffffff82000000 2028K ro NX pte
0xffffffff82000000-0xffffffff8214f000 1340K RW GLB NX pte
0xffffffff8214f000-0xffffffff82281000 1224K RW NX pte
0xffffffff82281000-0xffffffff82400000 1532K RW GLB NX pte
0xffffffff82400000-0xffffffff83200000 14M RW PSE GLB NX pmd
0xffffffff83200000-0xffffffffc0000000 974M pmd
After:
[ 0.145062] vDSO @ ffffffff81da1000
[ 0.146057] vDSO @ ffffffff81da4000
---[ High Kernel Mapping ]---
0xffffffff80000000-0xffffffff81000000 16M pmd
0xffffffff81000000-0xffffffff81800000 8M ro PSE GLB x pmd
0xffffffff81800000-0xffffffff819f3000 1996K ro GLB x pte
0xffffffff819f3000-0xffffffff81a00000 52K ro NX pte
0xffffffff81a00000-0xffffffff81e00000 4M ro PSE GLB NX pmd
0xffffffff81e00000-0xffffffff81e0b000 44K ro GLB NX pte
0xffffffff81e0b000-0xffffffff82000000 2004K ro NX pte
0xffffffff82000000-0xffffffff8214c000 1328K RW GLB NX pte
0xffffffff8214c000-0xffffffff8227e000 1224K RW NX pte
0xffffffff8227e000-0xffffffff82400000 1544K RW GLB NX pte
0xffffffff82400000-0xffffffff83200000 14M RW PSE GLB NX pmd
0xffffffff83200000-0xffffffffc0000000 974M pmd
Based on work by PaX Team and Brad Spengler.
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Andy Lutomirski <luto@kernel.org>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Brown <david.brown@linaro.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathias Krause <minipli@googlemail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kernel-hardening@lists.openwall.com
Cc: linux-arch <linux-arch@vger.kernel.org>
Link: http://lkml.kernel.org/r/1455748879-21872-7-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/entry/vdso/vdso2c.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h
index 0224987..3f69326 100644
--- a/arch/x86/entry/vdso/vdso2c.h
+++ b/arch/x86/entry/vdso/vdso2c.h
@@ -140,7 +140,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
fprintf(outfile, "#include <asm/vdso.h>\n");
fprintf(outfile, "\n");
fprintf(outfile,
- "static unsigned char raw_data[%lu] __page_aligned_data = {",
+ "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
mapping_size);
for (j = 0; j < stripped_len; j++) {
if (j % 10 == 0)
next prev parent reply other threads:[~2016-02-22 12:20 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 22:41 [PATCH v5 0/7] introduce post-init read-only memory Kees Cook
2016-02-17 22:41 ` [PATCH v5 1/7] asm-generic: consolidate mark_rodata_ro() Kees Cook
2016-02-19 14:38 ` Will Deacon
2016-02-22 12:18 ` [tip:mm/readonly] asm-generic: Consolidate mark_rodata_ro() =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-22 12:18 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 22:41 ` [PATCH v5 2/7] init: create cmdline param to disable readonly Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:18 ` [tip:mm/readonly] mm/init: Add 'rodata=off' boot cmdline parameter to disable read-only kernel mappings =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-22 12:18 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 22:41 ` [PATCH v5 3/7] x86: make CONFIG_DEBUG_RODATA non-optional Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:19 ` [tip:mm/readonly] x86/mm: Always enable CONFIG_DEBUG_RODATA and remove the Kconfig option =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-22 12:19 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 22:41 ` [PATCH v5 4/7] introduce post-init read-only memory Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:19 ` [tip:mm/readonly] arch: Introduce " =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-22 12:19 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-03-07 13:00 ` [PATCH v5 4/7] introduce " Christian Borntraeger
2016-03-08 0:16 ` Kees Cook
2016-03-08 0:16 ` Kees Cook
2016-03-08 0:23 ` Andy Lutomirski
2016-03-08 0:23 ` Andy Lutomirski
2016-02-17 22:41 ` [PATCH v5 5/7] lkdtm: verify that __ro_after_init works correctly Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:19 ` [tip:mm/readonly] lkdtm: Verify that '__ro_after_init' " =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-22 12:19 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 22:41 ` [PATCH v5 6/7] x86, vdso: mark vDSO read-only after init Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:20 ` =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?= [this message]
2016-02-22 12:20 ` [tip:mm/readonly] x86/vdso: Mark the vDSO code " =?UTF-8?B?dGlwLWJvdCBmb3IgS2VlcyBDb29rIDx0aXBib3RAenl0b3IuY29tPg==?=
2016-02-17 22:41 ` [PATCH v5 7/7] ARM: vdso: Mark vDSO code as read-only Kees Cook
2016-02-17 22:41 ` Kees Cook
2016-02-22 12:20 ` [tip:mm/readonly] ARM/vdso: Mark the vDSO code read-only after init =?UTF-8?B?dGlwLWJvdCBmb3IgRGF2aWQgQnJvd24gPHRpcGJvdEB6eXRvci5jb20+?=
2016-02-22 12:20 ` =?UTF-8?B?dGlwLWJvdCBmb3IgRGF2aWQgQnJvd24gPHRpcGJvdEB6eXRvci5jb20+?=
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=tip-018ef8dcf3de5f62e2cc1a9273cc27e1c6ba8de5@git.kernel.org \
--to==?utf-8?b?dglwlwjvdcbmb3igs2vlcybdb29ridx0axbib3raenl0b3iuy29tpg==?=@zytor.com \
--cc==?UTF-8?B?bGludXgtdGlwLWNvbW1pdHNAdmdlci5rZXJuZWwub3Jn?=@zytor.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=david.brown@linaro.org \
--cc=dvlasenk@redhat.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=minipli@googlemail.com \
--cc=mpe@ellerman.id.au \
--cc=pageexec@freemail.hu \
--cc=peterz@infradead.org \
--cc=re.emese@gmail.com \
--cc=spender@grsecurity.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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).