linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] check put_user fail in do_signal when enable OABI_COMPACT
@ 2009-10-21 11:07 Janboe Ye
  2009-10-22  3:35 ` ye janboe
  0 siblings, 1 reply; 29+ messages in thread
From: Janboe Ye @ 2009-10-21 11:07 UTC (permalink / raw)
  To: linux-arm-kernel

Using OABI, do_signal need to copy restart_syscall to user stack.
It is possible that put_user fail. This triggers flush_icache page
fault and crash kernel.

Signed-off-by: janboe <janboe.ye@gmail.com>
---
 arch/arm/kernel/signal.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index f6bc5d4..2122d43 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -626,6 +626,7 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
 	struct k_sigaction ka;
 	siginfo_t info;
 	int signr;
+	int ret = 0;
 
 	/*
 	 * We want the common case to go fast, which
@@ -679,16 +680,20 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
 				 */
 				swival = swival - __NR_SYSCALL_BASE + __NR_OABI_SYSCALL_BASE;
 
-				put_user(regs->ARM_pc, &usp[0]);
+				ret |= put_user(regs->ARM_pc, &usp[0]);
 				/* swi __NR_restart_syscall */
-				put_user(0xef000000 | swival, &usp[1]);
+				ret |= put_user(0xef000000 | swival, &usp[1]);
 				/* ldr	pc, [sp], #12 */
-				put_user(0xe49df00c, &usp[2]);
-
-				flush_icache_range((unsigned long)usp,
-						   (unsigned long)(usp + 3));
-
-				regs->ARM_pc = regs->ARM_sp + 4;
+				ret |= put_user(0xe49df00c, &usp[2]);
+				if (!ret) {
+					flush_icache_range((unsigned long)usp,
+						(unsigned long)(usp + 3));
+
+					regs->ARM_pc = regs->ARM_sp + 4;
+				} else {
+					regs->ARM_sp += 12;
+					force_sigsegv(0, current);
+				}
 #endif
 			}
 		}
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2009-11-23 16:20 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-21 11:07 [PATCH] check put_user fail in do_signal when enable OABI_COMPACT Janboe Ye
2009-10-22  3:35 ` ye janboe
2009-10-24 10:49   ` Russell King - ARM Linux
2009-10-25  6:23     ` ye janboe
2009-10-25 15:44       ` Russell King - ARM Linux
2009-10-26  2:59         ` ye janboe
2009-10-27 14:14           ` Jean Pihet
2009-10-27 14:28             ` Russell King - ARM Linux
2009-10-27 14:41               ` ye janboe
2009-10-27 15:42             ` Mikael Pettersson
2009-10-27 17:57               ` Jean Pihet
2009-10-27 18:08                 ` Nicolas Pitre
2009-10-27 18:37                   ` Jean Pihet
2009-10-27 18:59                     ` Nicolas Pitre
2009-10-27 19:12                       ` Jean Pihet
2009-10-27 19:35                         ` Nicolas Pitre
2009-10-27 19:42                           ` Russell King - ARM Linux
2009-10-27 19:52                             ` Nicolas Pitre
2009-10-28 10:16                           ` Jean Pihet
2009-10-28 16:13                             ` Nicolas Pitre
2009-10-28 16:23                               ` Jean Pihet
2009-10-28 17:00                                 ` Jean Pihet
2009-10-28 17:24                                   ` Nicolas Pitre
2009-10-28 19:32                                   ` Jamie Lokier
2009-11-04 13:33                                   ` Jean Pihet
2009-11-04 19:32                                     ` Russell King - ARM Linux
2009-11-23 13:59                                       ` Jean Pihet
2009-11-23 14:06                                         ` Russell King - ARM Linux
2009-11-23 16:20                                           ` Jean Pihet

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).