From: jpihet@mvista.com (Jean Pihet)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] check put_user fail in do_signal when enable OABI_COMPACT
Date: Tue, 27 Oct 2009 18:57:34 +0100 [thread overview]
Message-ID: <200910271857.35371.jpihet@mvista.com> (raw)
In-Reply-To: <19175.5363.259051.477820@pilspetsen.it.uu.se>
Hi,
On Tuesday 27 October 2009 16:42:43 Mikael Pettersson wrote:
...
>
> I don't like this 'ret' variable:
> - it's only for OABI, but declared at the top and initialised also for EABI
> - you update it with |=, but clearly there's no useful previous value
>
> I'd drop 'ret' and just do:
>
> if (put_user(regs->ARM_pc, usp) == 0) {
> flush...
> } else {
> ... force_sigsegv
> }
>
> (Note: == 0 not !, since ! is often read as "failed" whereas for
> put_user() 0 means Ok and non-zero means -errno.)
Yes that improves the code readability. Thanks for the suggestion.
Here is an updated patch.
Regards,
Jean
>From 885a5952dd38bc0c023e52f731ea2681d43132ba Mon Sep 17 00:00:00 2001
From: Jean Pihet <jpihet@mvista.com>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Check put_user fail in do_signal when enable OABI_COMPAT
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>
Merged from
http://lists.infradead.org/pipermail/linux-arm-kernel/2009-October/002621.html
on top of
http://marc.info/?l=linux-arm-kernel&m=125638133624452&w=2
Tested with multiple sleeping apps/threads (using the nanosleep syscall) and
suspend/resume.
Signed-off-by: Jean Pihet <jpihet@mvista.com>
---
arch/arm/kernel/signal.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index f330974..4366cc0 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -676,8 +676,14 @@ static int do_signal(sigset_t *oldset, struct pt_regs
*regs, int syscall)
regs->ARM_sp -= 4;
usp = (u32 __user *)regs->ARM_sp;
- put_user(regs->ARM_pc, usp);
- regs->ARM_pc = KERN_RESTART_CODE;
+ if (put_user(regs->ARM_pc, usp) == 0) {
+ flush_icache_range((unsigned long)usp,
+ (unsigned long)(usp + 1));
+ regs->ARM_pc = KERN_RESTART_CODE;
+ } else {
+ regs->ARM_sp += 4;
+ force_sigsegv(0, current);
+ }
#endif
}
}
--
1.6.2.5.168.g3823
next prev parent reply other threads:[~2009-10-27 17:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=200910271857.35371.jpihet@mvista.com \
--to=jpihet@mvista.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 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).