check put_user fail in do_signal when enable OABI_COMPACT
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
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.
--- arch/arm/kernel/signal.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-)
arch/arm/kernel/signal.c +13 -8
@@ -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 } }
Signature · 1 line
1.6.3.3
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
hi,
No one think that it is possible that put_user could fail in some situation even if currently kernel subtract 12 from ARM_sp and cross page bound?
Thanks
Janboe
2009/10/21 Janboe Ye <[email protected]>:
Quoted 59 lines
Using OABI,
do_signalneed to copyrestart_syscallto user stack. It is possible thatput_userfail. This triggersflush_icachepage fault and crash kernel.Signed-off-by janboe <[email protected]>---
?arch/arm/kernel/signal.c | ? 21 +++++++++++++-------- ?1 files changed, 13 insertions(+), 8 deletions(-)arch/arm/kernel/signal.c +1
-0@@ -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, whicharch/arm/kernel/signal.c +0
-0@@ -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]);arch/arm/kernel/signal.c +10
-5- - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 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_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 4 lines · ye janboe
hi,
No one think that it is possible thatput_usercould fail in some situation even if currently kernel subtract 12 fromARM_spand cross page bound?
It is possible, and it's something we should fix. Note there's another fix in this area (I've just posted) which will make your patch invalid. Please wait until we've sorted out this other patch.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
hi, Russell
Your patch looks good for real fixing this issue.
2009/10/24 Russell King - ARM Linux <[email protected]>:
Quoted 10 lines · ye janboe
Quoted 4 lines
hi,
No one think that it is possible thatput_usercould fail in some situation even if currently kernel subtract 12 fromARM_spand cross page bound?It is possible, and it's something we should fix. ?Note there's another fix in this area (I've just posted) which will make your patch invalid. Please wait until we've sorted out this other patch.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 3 lines · ye janboe
hi, Russell
Your patch looks good for real fixing this issue.
My patch doesn't address your issue, it only addresses a previous problem. We're still decrementing the stack pointer and writing to a possible new page - which could fault.
Therefore, your patch is still required, but it needs to be modified to apply on top of my patch.
A replacement patch would be welcome.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Sure. Russell
After you restart_syscall patch are merged, I will send out another patch.
Thanks
2009/10/25 Russell King - ARM Linux <[email protected]>:
Quoted 14 lines · ye janboe
Quoted 3 lines
hi, Russell
Your patch looks good for real fixing this issue.
My patch doesn't address your issue, it only addresses a previous problem. ?We're still decrementing the stack pointer and writing to a possible new page - which could fault.
Therefore, your patch is still required, but it needs to be modified to apply on top of my patch.
A replacement patch would be welcome.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Russell, Janboe,
Quoted 3 lines · On Monday 26 October 2009 03:59:23 ye janboe wrote:
Sure. Russell
After you
restart_syscallpatch are merged, I will send out another patch.
Here is what I ended up with after merging.
It has been tested on OMAP3 boards although I could not trigger the failing put_user test case.
What do you think?
Regards,
Jean
Quoted 1 line
From
dcaf0812f86948fe1c9dbb9fe53e9040f5a6deebMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
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.
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.
--- arch/arm/kernel/signal.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/kernel/signal.c +0 -0
@@ -643,6 +643,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
@@ -685,8 +686,15 @@ 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;
+ ret |= put_user(regs->ARM_pc, usp);
+ if (!ret) {
+ 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
}
}
Quoted 22 lines
Thanks
2009/10/25 Russell King - ARM Linux <[email protected]>:
Quoted 5 lines · ye janboe
Quoted 3 lines
hi, Russell
Your patch looks good for real fixing this issue.
Quoted 8 lines
My patch doesn't address your issue, it only addresses a previous problem. ?We're still decrementing the stack pointer and writing to a possible new page - which could fault.
Therefore, your patch is still required, but it needs to be modified to apply on top of my patch.
A replacement patch would be welcome.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 11 lines · Jean Pihet
Russell, Janboe,
Quoted 3 lines · On Monday 26 October 2009 03:59:23 ye janboe wrote:
Sure. Russell
After you
restart_syscallpatch are merged, I will send out another patch.Here is what I ended up with after merging.
It has been tested on OMAP3 boards although I could not trigger the failingput_usertest case.What do you think?
Looks fine, thanks.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
looks fine too. Thanks
2009/10/27 Russell King - ARM Linux <[email protected]>:
Quoted 15 lines · Jean Pihet
Quoted 11 lines
Russell, Janboe,
Quoted 3 lines · On Monday 26 October 2009 03:59:23 ye janboe wrote:
Sure. Russell
After you
restart_syscallpatch are merged, I will send out another patch.Here is what I ended up with after merging.
It has been tested on OMAP3 boards although I could not trigger the failingput_usertest case.What do you think?
Looks fine, thanks.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
In reply to Jean PihetQuoted 18 lines · Jean Pihet
arch/arm/kernel/signal.c +1
-0@@ -643,6 +643,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 ;/* arch/arm/kernel/signal.c +0
-2* We want the common case to go fast, which @@ -685,8 +686,15 @@ 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 ;
arch/arm/kernel/signal.c static int do_signal(sigset_t *oldset, struct pt_regs · line 699
Quoted 10 lines
arch/arm/kernel/signal.c +9
-0+ ret |=put_user (regs->ARM_pc, usp); +if (!ret) { +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
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.)
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Hi,
On Tuesday 27 October 2009 16:42:43 Mikael Pettersson wrote:
...
Quoted 7 lines
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 valueI'd drop 'ret' and just do:
Quoted 8 lines
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
Quoted 1 line
From
885a5952dd38bc0c023e52f731ea2681d43132baMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
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.
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.
--- arch/arm/kernel/signal.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/kernel/signal.c +0 -0
@@ -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
}
}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 5 lines · Jean Pihet
arch/arm/kernel/signal.c +0
-0
arch/arm/kernel/signal.c static int do_signal(sigset_t *oldset, struct pt_regs · line 682
Quoted 9 lines
arch/arm/kernel/signal.c +3
-2@@ -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 ));
Why are you flushing the icache? There is no code on the stack anymore.
Nicolas
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 10 lines · On Tuesday 27 October 2009 19:08:07 Nicolas Pitre wrote:
Quoted 9 lines · Jean Pihet
arch/arm/kernel/signal.c +0
-0@@ -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;
Quoted 7 lines
arch/arm/kernel/signal.c static int do_signal(sigset_t *oldset, struct · line 682
Quoted 5 lines
arch/arm/kernel/signal.c +3
-2-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 ));Why are you flushing the icache? There is no code on the stack anymore.
Yes indeed there is no more code modified.
Side question: does the put_user requires a flush of some sort? If not, why?
Is it OK to re-send a patch with the call to flush_icache_range removed?
Thanks!
Quoted 1 line
Nicolas
Jean
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 18 lines · Jean Pihet
Quoted 10 lines · On Tuesday 27 October 2009 19:08:07 Nicolas Pitre wrote:
Quoted 9 lines · Jean Pihet
arch/arm/kernel/signal.c +0
-0@@ -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;Quoted 7 lines
arch/arm/kernel/signal.c static int do_signal(sigset_t *oldset, struct · line 682
Quoted 5 lines
arch/arm/kernel/signal.c +3
-2-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 ));Why are you flushing the icache? There is no code on the stack anymore.
Quoted 2 lines
Yes indeed there is no more code modified.
Side question: does theput_userrequires a flush of some sort? If not, why?
No because it stores data into the d-cache directly at the virtual address to be used by user space. Previously the d-cache needed to be cleaned for data to hit main memory and the i-cache invalidated for the newly stored _code_ to be seen by the instruction path. Since there is no code involved anymore the cache flushes are useless.
Quoted 1 line
Is it OK to re-send a patch with the call to
flush_icache_rangeremoved?
Yes.
Nicolas
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Nicolas,
On Tuesday 27 October 2009 19:59:36 Nicolas Pitre wrote:
...
Quoted 9 lines
Quoted 2 lines
Side question: does the
put_userrequires a flush of some sort? If not, why?No because it stores data into the d-cache directly at the virtual address to be used by user space. Previously the d-cache needed to be cleaned for data to hit main memory and the i-cache invalidated for the newly stored _code_ to be seen by the instruction path. Since there is no code involved anymore the cache flushes are useless.
Quoted 3 lines
Quoted 1 line
Is it OK to re-send a patch with the call to
flush_icache_rangeremoved?Yes.
Ok here is the updated patch. Let's hope it is the good one that time ;-)
Can it be merged? It applies cleanly on top of Russell's latest patch
(http://marc.info/?l=linux-arm-kernel&m=125638133624452&w=2).
Quoted 3 lines
Nicolas
Regards,
Jean
---
Quoted 1 line
From
d862e03679f7ea44fca1bf1ea256bbade3fbe76aMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
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.
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.
--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/kernel/signal.c +0 -0
@@ -676,8 +676,12 @@ 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) {
+ regs->ARM_pc = KERN_RESTART_CODE;
+ } else {
+ regs->ARM_sp += 4;
+ force_sigsegv(0, current);
+ }
#endif
}
}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 13 lines · Jean Pihet
Nicolas,
On Tuesday 27 October 2009 19:59:36 Nicolas Pitre wrote:
...Quoted 9 lines
Quoted 2 lines
Side question: does the
put_userrequires a flush of some sort? If not, why?No because it stores data into the d-cache directly at the virtual address to be used by user space. Previously the d-cache needed to be cleaned for data to hit main memory and the i-cache invalidated for the newly stored _code_ to be seen by the instruction path. Since there is no code involved anymore the cache flushes are useless.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Is it OK to re-send a patch with the call to
flush_icache_rangeremoved?Yes.
Ok here is the updated patch. Let's hope it is the good one that time ;-)
Well, the commit message is certainly wrong. There is no copying of restart_syscall to user stack anymore.
And is there a reason for touching sp in the error case?
Quoted 59 lines
Can it be merged? It applies cleanly on top of Russell's latest patch
(http://marc.info/?l=linux-arm-kernel&m=125638133624452&w=2).Quoted 3 lines
Nicolas
Regards,
Jean---
Fromd862e03679f7ea44fca1bf1ea256bbade3fbe76aMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Checkput_userfail indo_signalwhen enableOABI_COMPATUsing OABI,
do_signalneed to copyrestart_syscallto user stack. It is possible thatput_userfail. This triggersflush_icachepage fault and crash kernel.Signed-off-by janboe <[email protected]>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=2Tested with multiple sleeping apps/threads (using the nanosleep syscall) and suspend/resume.
Signed-off-by Jean Pihet <[email protected]>--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)arch/arm/kernel/signal.c +6
-2@@ -676,8 +676,12 @@ 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 ) { + regs->ARM_pc =KERN_RESTART_CODE ; + }else { + regs->ARM_sp +=4 ; +force_sigsegv (0 , current); + }#endif }}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 17 lines · Nicolas Pitre
Quoted 15 lines · Jean Pihet
Nicolas,
On Tuesday 27 October 2009 19:59:36 Nicolas Pitre wrote:
...Quoted 11 lines
Quoted 2 lines
Side question: does the
put_userrequires a flush of some sort? If not, why?No because it stores data into the d-cache directly at the virtual address to be used by user space. Previously the d-cache needed to be cleaned for data to hit main memory and the i-cache invalidated for the newly stored _code_ to be seen by the instruction path. Since there is no code involved anymore the cache flushes are useless.
Quoted 1 line
Is it OK to re-send a patch with the call to
flush_icache_rangeremoved?
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Yes.
Ok here is the updated patch. Let's hope it is the good one that time ;-)
Well, the commit message is certainly wrong. There is no copying of
restart_syscallto user stack anymore.And is there a reason for touching sp in the error case?
Returning 'sp' seems to be a sane thing to do - otherwise debuggers analysing core dumps could be confused about the location of data on the stack.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 6 lines · Russell King - ARM Linux
Quoted 1 line · Nicolas Pitre
And is there a reason for touching sp in the error case?
Returning 'sp' seems to be a sane thing to do - otherwise debuggers analysing core dumps could be confused about the location of data on the stack.
Good point.
Nicolas
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
In reply to Nicolas PitreQuoted 18 lines · On Tuesday 27 October 2009 20:35:31 Nicolas Pitre wrote:
Quoted 17 lines · Jean Pihet
Nicolas,
On Tuesday 27 October 2009 19:59:36 Nicolas Pitre wrote:
...Quoted 12 lines
Quoted 2 lines
Side question: does the
put_userrequires a flush of some sort? If not, why?No because it stores data into the d-cache directly at the virtual address to be used by user space. Previously the d-cache needed to be cleaned for data to hit main memory and the i-cache invalidated for the newly stored _code_ to be seen by the instruction path. Since there is no code involved anymore the cache flushes are useless.
Quoted 2 lines
Is it OK to re-send a patch with the call to
flush_icache_rangeremoved?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Yes.
Ok here is the updated patch. Let's hope it is the good one that time ;-)
Well, the commit message is certainly wrong. There is no copying of
restart_syscallto user stack anymore.
Ok thanks for reviewing it! Here is a respin of the patch. Only the commit description has been touched.
Quoted 5 lines
And is there a reason for touching sp in the error case?
Quoted 2 lines
Can it be merged? It applies cleanly on top of Russell's latest patch
(http://marc.info/?l=linux-arm-kernel&m=125638133624452&w=2).
Same question: can those 2 patches be merged in? Can they be acked-by?
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Nicolas
Thanks,
Jean
Quoted 1 line
Quoted 1 line
---
Quoted 1 line
From
28336b68b2e2507ba0922c55147e5e72ec1a88dcMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Check put_user fail in do_signal when enable OABI_COMPAT
Using OABI, the call to put_user in do_signal can fail. In that case flush_icache page faults and the calling app goes in an infinite loop.
The solution is to check if put_user fails and force the app to seg fault in that case.
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.
--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/kernel/signal.c +0 -0
@@ -676,8 +676,12 @@ 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) {
+ regs->ARM_pc = KERN_RESTART_CODE;
+ } else {
+ regs->ARM_sp += 4;
+ force_sigsegv(0, current);
+ }
#endif
}
}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 5 lines · Jean Pihet
Quoted 2 lines · On Tuesday 27 October 2009 20:35:31 Nicolas Pitre wrote:
Well, the commit message is certainly wrong. There is no copying of
restart_syscallto user stack anymore.Ok thanks for reviewing it! Here is a respin of the patch. Only the commit description has been touched.
[...]
Quoted 2 lines
Using OABI, the call to
put_userindo_signalcan fail. In that caseflush_icachepage faults and the calling app goes in an infinite loop.
Still wrong. Why flush_icache?
Nicolas
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 8 lines · On Wednesday 28 October 2009 17:13:28 Nicolas Pitre wrote:
Quoted 6 lines · Jean Pihet
Quoted 2 lines · On Tuesday 27 October 2009 20:35:31 Nicolas Pitre wrote:
Well, the commit message is certainly wrong. There is no copying of
restart_syscallto user stack anymore.Ok thanks for reviewing it! Here is a respin of the patch. Only the commit description has been touched.
Quoted 6 lines
[...]
Quoted 2 lines
Using OABI, the call to
put_userindo_signalcan fail. In that caseflush_icachepage faults and the calling app goes in an infinite loop.Still wrong. Why
flush_icache?
Indeed that is wrong (again!). I had put it in the problem description but that does not apply anymore.
Thanks, will send an update.
Quoted 3 lines
Nicolas
Jean
Quoted 5 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
On Wednesday 28 October 2009 17:23:01 Jean Pihet wrote:
...
Quoted 6 lines
Quoted 1 line
Still wrong. Why
flush_icache?Indeed that is wrong (again!). I had put it in the problem description but that does not apply anymore.
Thanks, will send an update.
Here is the updated patch. Is it OK?
Jean
Quoted 5 lines
Quoted 2 lines
Nicolas
Jean
---
Quoted 1 line
From
28336b68b2e2507ba0922c55147e5e72ec1a88dcMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Check put_user fail in do_signal when enable OABI_COMPAT
Source: Janboe Ye <[email protected]>
MR: 36048
Type: Defect Fix
Disposition: Submitted to linux-arm-kernel ML
ChangeID: 689ddf707d2232e9cf01387ac1264bc8812b9ffd Description:
Using OABI, the call to put_user in do_signal can fail causing the calling app to hang.
The solution is to check if put_user fails and force the app to seg fault in that case.
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.
--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/kernel/signal.c +0 -0
@@ -676,8 +676,12 @@ 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) {
+ regs->ARM_pc = KERN_RESTART_CODE;
+ } else {
+ regs->ARM_sp += 4;
+ force_sigsegv(0, current);
+ }
#endif
}
}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 9 lines · Jean Pihet
On Wednesday 28 October 2009 17:23:01 Jean Pihet wrote:
...Quoted 6 lines
Quoted 1 line
Still wrong. Why
flush_icache?Indeed that is wrong (again!). I had put it in the problem description but that does not apply anymore.
Thanks, will send an update.
Here is the updated patch. Is it OK?
ACK.
Quoted 58 lines
---
From28336b68b2e2507ba0922c55147e5e72ec1a88dcMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Checkput_userfail indo_signalwhen enableOABI_COMPATSource: Janboe Ye <[email protected]>
MR: 36048
Type: Defect Fix
Disposition: Submitted to linux-arm-kernel ML
ChangeID:689ddf707d2232e9cf01387ac1264bc8812b9ffdDescription:Using OABI, the call to
put_userindo_signalcan fail causing the calling app to hang.The solution is to check if
put_userfails and force the app to seg fault in that case.Signed-off-by janboe <[email protected]>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=2Tested with multiple sleeping apps/threads (using the nanosleep syscall) and suspend/resume.
Signed-off-by Jean Pihet <[email protected]>--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)arch/arm/kernel/signal.c +6
-2@@ -676,8 +676,12 @@ 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 ) { + regs->ARM_pc =KERN_RESTART_CODE ; + }else { + regs->ARM_sp +=4 ; +force_sigsegv (0 , current); + }#endif }}
Signature · 1 line
1.6.2.5.168.g3823
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
In reply to Jean PihetReview
Quoted 13 lines · Jean Pihet
(quoted diff) +6
-2usp = (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) { + regs->ARM_pc = KERN_RESTART_CODE; + } else { + regs->ARM_sp += 4; + force_sigsegv(0, current); + } #endif } }
This one looks good to me.
-- Jamie
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
In reply to Jean PihetRussell,
Is this one OK? Can it be merged now that your fix for signal restart has been merged into mainline?
Regards,
Jean
Quoted 72 lines · On Wednesday 28 October 2009 18:00:47 Jean Pihet wrote:
On Wednesday 28 October 2009 17:23:01 Jean Pihet wrote:
...Quoted 6 lines
Quoted 1 line
Still wrong. Why
flush_icache?Indeed that is wrong (again!). I had put it in the problem description but that does not apply anymore.
Thanks, will send an update.
Here is the updated patch. Is it OK?
Jean
Quoted 3 lines
Quoted 1 line
Nicolas
Jean
---
From28336b68b2e2507ba0922c55147e5e72ec1a88dcMon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Tue, 27 Oct 2009 10:09:22 +0100
Subject: ARM: Checkput_userfail indo_signalwhen enableOABI_COMPATSource: Janboe Ye <[email protected]>
MR: 36048
Type: Defect Fix
Disposition: Submitted to linux-arm-kernel ML
ChangeID:689ddf707d2232e9cf01387ac1264bc8812b9ffdDescription:Using OABI, the call to
put_userindo_signalcan fail causing the calling app to hang.The solution is to check if
put_userfails and force the app to seg fault in that case.Signed-off-by janboe <[email protected]>Merged from
http://lists.infradead.org/pipermail/linux-arm-kernel/2009-October/002621.h
tml on top of
http://marc.info/?l=linux-arm-kernel&m=125638133624452&w=2Tested with multiple sleeping apps/threads (using the nanosleep syscall) and suspend/resume.
Signed-off-by Jean Pihet <[email protected]>--- arch/arm/kernel/signal.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)arch/arm/kernel/signal.c +6
-2@@ -676,8 +676,12 @@ 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 ) { + regs->ARM_pc =KERN_RESTART_CODE ; + }else { + regs->ARM_sp +=4 ; +force_sigsegv (0 , current); + }#endif }}
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 2 lines · Jean Pihet
Is this one OK? Can it be merged now that your fix for signal restart has been merged into mainline?
Yes.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Russell,
Quoted 5 lines · On Wednesday 04 November 2009 20:32:44 Russell King - ARM Linux wrote:
Quoted 2 lines · Jean Pihet
Is this one OK? Can it be merged now that your fix for signal restart has been merged into mainline?
Yes.
May I ask you again to merge the patch? Is this one supposed to reach into mainline via your tree?
Regards,
Jean
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 10 lines · Jean Pihet
Russell,
Quoted 5 lines · On Wednesday 04 November 2009 20:32:44 Russell King - ARM Linux wrote:
Quoted 2 lines · Jean Pihet
Is this one OK? Can it be merged now that your fix for signal restart has been merged into mainline?
Yes.
May I ask you again to merge the patch? Is this one supposed to reach into mainline via your tree?
I have a patch system to avoid patches being dropped like this... I'm really *bad* with emailed patches.
Please submit to the patch system, thanks.
PATCH 1/1 check put_user fail in do_signal when enable OABI_COMPACT
Quoted 10 lines · On Monday 23 November 2009 15:06:50 Russell King - ARM Linux wrote:
Quoted 9 lines · Jean Pihet
Russell,
Quoted 5 lines · On Wednesday 04 November 2009 20:32:44 Russell King - ARM Linux wrote:
Quoted 2 lines · Jean Pihet
Is this one OK? Can it be merged now that your fix for signal restart has been merged into mainline?
Yes.
Quoted 7 lines
Quoted 2 lines
May I ask you again to merge the patch? Is this one supposed to reach into mainline via your tree?
I have a patch system to avoid patches being dropped like this... I'm really *bad* with emailed patches.
Please submit to the patch system, thanks.
Ah ok! It is submitted as patch 5793/1.
Thanks,
Jean