Commit-ID:  11bf9b865898961cee60a41c483c9f27ec76e12e
Gitweb:     http://git.kernel.org/tip/11bf9b865898961cee60a41c483c9f27ec76e12e
Author:     David Brown <david.br...@linaro.org>
AuthorDate: Wed, 17 Feb 2016 14:41:18 -0800
Committer:  Ingo Molnar <mi...@kernel.org>
CommitDate: Mon, 22 Feb 2016 08:51:39 +0100

ARM/vdso: Mark the vDSO code read-only after init

Although the ARM vDSO is cleanly separated by code/data with the code
being read-only in userspace mappings, the code page is still writable
from the kernel.

There have been exploits (such as http://itszn.com/blog/?p=21) that
take advantage of this on x86 to go from a bad kernel write to full
root.

Prevent this specific exploit class on ARM as well by putting the vDSO
code page in post-init read-only memory as well.

Before:
        vdso: 1 text pages at base 80927000
        root@Vexpress:/ cat /sys/kernel/debug/kernel_page_tables
        ---[ Modules ]---
        ---[ Kernel Mapping ]---
        0x80000000-0x80100000           1M     RW NX SHD
        0x80100000-0x80600000           5M     ro x  SHD
        0x80600000-0x80800000           2M     ro NX SHD
        0x80800000-0xbe000000         984M     RW NX SHD

After:
        vdso: 1 text pages at base 8072b000
        root@Vexpress:/ cat /sys/kernel/debug/kernel_page_tables
        ---[ Modules ]---
        ---[ Kernel Mapping ]---
        0x80000000-0x80100000           1M     RW NX SHD
        0x80100000-0x80600000           5M     ro x  SHD
        0x80600000-0x80800000           2M     ro NX SHD
        0x80800000-0xbe000000         984M     RW NX SHD

Inspired by https://lkml.org/lkml/2016/1/19/494 based on work by the
PaX Team, Brad Spengler, and Kees Cook.

Signed-off-by: David Brown <david.br...@linaro.org>
Signed-off-by: Kees Cook <keesc...@chromium.org>
Cc: Andy Lutomirski <l...@amacapital.net>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Brad Spengler <spen...@grsecurity.net>
Cc: Brian Gerst <brge...@gmail.com>
Cc: Denys Vlasenko <dvlas...@redhat.com>
Cc: Emese Revfy <re.em...@gmail.com>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Mathias Krause <mini...@googlemail.com>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Nathan Lynch <nathan_ly...@mentor.com>
Cc: PaX Team <pagee...@freemail.hu>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Russell King <li...@arm.linux.org.uk>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: kernel-harden...@lists.openwall.com
Cc: linux-arch <linux-a...@vger.kernel.org>
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1455748879-21872-8-git-send-email-keesc...@chromium.org
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 arch/arm/vdso/vdso.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/vdso/vdso.S b/arch/arm/vdso/vdso.S
index b2b97e3..a62a7b6 100644
--- a/arch/arm/vdso/vdso.S
+++ b/arch/arm/vdso/vdso.S
@@ -23,9 +23,8 @@
 #include <linux/const.h>
 #include <asm/page.h>
 
-       __PAGE_ALIGNED_DATA
-
        .globl vdso_start, vdso_end
+       .section .data..ro_after_init
        .balign PAGE_SIZE
 vdso_start:
        .incbin "arch/arm/vdso/vdso.so"

Reply via email to