diff options
author | Andy Lutomirski <luto@amacapital.net> | 2015-02-12 18:01:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 21:54:12 -0500 |
commit | f56141e3e2d9aabf7e6b89680ab572c2cdbb2a24 (patch) | |
tree | 481e3d99bc1121ce75d505d340153b9d158e60c5 /arch/powerpc | |
parent | edc924e023ae2022fc29f1246e115c610c9abf38 (diff) |
all arches, signal: move restart_block to struct task_struct
If an attacker can cause a controlled kernel stack overflow, overwriting
the restart block is a very juicy exploit target. This is because the
restart_block is held in the same memory allocation as the kernel stack.
Moving the restart block to struct task_struct prevents this exploit by
making the restart_block harder to locate.
Note that there are other fields in thread_info that are also easy
targets, at least on some architectures.
It's also a decent simplification, since the restart code is more or less
identical on all architectures.
[james.hogan@imgtec.com: metag: align thread_info::supervisor_stack]
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: David Miller <davem@davemloft.net>
Acked-by: Richard Weinberger <richard@nod.at>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Steven Miao <realmz6@gmail.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Tested-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Chen Liqin <liqin.linux@gmail.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/thread_info.h | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/signal_32.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/signal_64.c | 2 |
3 files changed, 3 insertions, 7 deletions
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index e8abc83e699f..72489799cf02 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h | |||
@@ -43,7 +43,6 @@ struct thread_info { | |||
43 | int cpu; /* cpu we're on */ | 43 | int cpu; /* cpu we're on */ |
44 | int preempt_count; /* 0 => preemptable, | 44 | int preempt_count; /* 0 => preemptable, |
45 | <0 => BUG */ | 45 | <0 => BUG */ |
46 | struct restart_block restart_block; | ||
47 | unsigned long local_flags; /* private flags for thread */ | 46 | unsigned long local_flags; /* private flags for thread */ |
48 | 47 | ||
49 | /* low level flags - has atomic operations done on it */ | 48 | /* low level flags - has atomic operations done on it */ |
@@ -59,9 +58,6 @@ struct thread_info { | |||
59 | .exec_domain = &default_exec_domain, \ | 58 | .exec_domain = &default_exec_domain, \ |
60 | .cpu = 0, \ | 59 | .cpu = 0, \ |
61 | .preempt_count = INIT_PREEMPT_COUNT, \ | 60 | .preempt_count = INIT_PREEMPT_COUNT, \ |
62 | .restart_block = { \ | ||
63 | .fn = do_no_restart_syscall, \ | ||
64 | }, \ | ||
65 | .flags = 0, \ | 61 | .flags = 0, \ |
66 | } | 62 | } |
67 | 63 | ||
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index b171001698ff..d3a831ac0f92 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c | |||
@@ -1231,7 +1231,7 @@ long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, | |||
1231 | int tm_restore = 0; | 1231 | int tm_restore = 0; |
1232 | #endif | 1232 | #endif |
1233 | /* Always make any pending restarted system calls return -EINTR */ | 1233 | /* Always make any pending restarted system calls return -EINTR */ |
1234 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 1234 | current->restart_block.fn = do_no_restart_syscall; |
1235 | 1235 | ||
1236 | rt_sf = (struct rt_sigframe __user *) | 1236 | rt_sf = (struct rt_sigframe __user *) |
1237 | (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16); | 1237 | (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16); |
@@ -1504,7 +1504,7 @@ long sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, | |||
1504 | #endif | 1504 | #endif |
1505 | 1505 | ||
1506 | /* Always make any pending restarted system calls return -EINTR */ | 1506 | /* Always make any pending restarted system calls return -EINTR */ |
1507 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 1507 | current->restart_block.fn = do_no_restart_syscall; |
1508 | 1508 | ||
1509 | sf = (struct sigframe __user *)(regs->gpr[1] + __SIGNAL_FRAMESIZE); | 1509 | sf = (struct sigframe __user *)(regs->gpr[1] + __SIGNAL_FRAMESIZE); |
1510 | sc = &sf->sctx; | 1510 | sc = &sf->sctx; |
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 2cb0c94cafa5..c7c24d2e2bdb 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c | |||
@@ -666,7 +666,7 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5, | |||
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | /* Always make any pending restarted system calls return -EINTR */ | 668 | /* Always make any pending restarted system calls return -EINTR */ |
669 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 669 | current->restart_block.fn = do_no_restart_syscall; |
670 | 670 | ||
671 | if (!access_ok(VERIFY_READ, uc, sizeof(*uc))) | 671 | if (!access_ok(VERIFY_READ, uc, sizeof(*uc))) |
672 | goto badframe; | 672 | goto badframe; |