All of lore.kernel.org
 help / color / mirror / Atom feed
From: yuan-bo.ye@motorola.com (Janboe Ye)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] check put_user fail in do_signal when enable OABI_COMPACT
Date: Wed, 21 Oct 2009 19:07:57 +0800	[thread overview]
Message-ID: <1256123277.3851.36.camel@debian-nb> (raw)

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

             reply	other threads:[~2009-10-21 11:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-21 11:07 Janboe Ye [this message]
2009-10-22  3:35 ` [PATCH] check put_user fail in do_signal when enable OABI_COMPACT 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

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=1256123277.3851.36.camel@debian-nb \
    --to=yuan-bo.ye@motorola.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.