* [PATCH RFC][try 2] IA64 signal : remove redundant code in setup_sigcontext()
@ 2007-11-22 3:15 Shi Weihua
2007-11-22 3:32 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: Shi Weihua @ 2007-11-22 3:15 UTC (permalink / raw)
To: linux-kernel; +Cc: tony.luck, linux-ia64
This patch removes some redundant code in the function setup_sigcontext().
The registers ar.ccv,b7,r14,ar.csd,ar.ssd,r2-r3 and r16-r31 are not restored
in restore_sigcontext() when (flags & IA64_SC_FLAG_IN_SYSCALL) is true.
So we don't need to zero those variables in setup_sigcontext().
Signed-off-by: Shi Weihua <shiwh@cn.fujitsu.com>
---
diff -urp linux-2.6.24-rc3-git1.orig/arch/ia64/kernel/signal.c linux-2.6.24-rc3-git1/arch/ia64/kernel/signal.c
--- linux-2.6.24-rc3-git1.orig/arch/ia64/kernel/signal.c 2007-11-17 13:16:36.000000000 +0800
+++ linux-2.6.24-rc3-git1/arch/ia64/kernel/signal.c 2007-11-22 11:02:27.000000000 +0800
@@ -280,15 +280,7 @@ setup_sigcontext (struct sigcontext __us
err |= __copy_to_user(&sc->sc_gr[15], &scr->pt.r15, 8); /* r15 */
err |= __put_user(scr->pt.cr_iip + ia64_psr(&scr->pt)->ri, &sc->sc_ip);
- if (flags & IA64_SC_FLAG_IN_SYSCALL) {
- /* Clear scratch registers if the signal interrupted a system call. */
- err |= __put_user(0, &sc->sc_ar_ccv); /* ar.ccv */
- err |= __put_user(0, &sc->sc_br[7]); /* b7 */
- err |= __put_user(0, &sc->sc_gr[14]); /* r14 */
- err |= __clear_user(&sc->sc_ar25, 2*8); /* ar.csd & ar.ssd */
- err |= __clear_user(&sc->sc_gr[2], 2*8); /* r2-r3 */
- err |= __clear_user(&sc->sc_gr[16], 16*8); /* r16-r31 */
- } else {
+ if (!(flags & IA64_SC_FLAG_IN_SYSCALL)) {
/* Copy scratch regs to sigcontext if the signal didn't interrupt a syscall. */
err |= __put_user(scr->pt.ar_ccv, &sc->sc_ar_ccv); /* ar.ccv */
err |= __put_user(scr->pt.b7, &sc->sc_br[7]); /* b7 */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC][try 2] IA64 signal : remove redundant code in setup_sigcontext()
2007-11-22 3:15 [PATCH RFC][try 2] IA64 signal : remove redundant code in setup_sigcontext() Shi Weihua
@ 2007-11-22 3:32 ` Matthew Wilcox
2007-12-18 23:29 ` Luck, Tony
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2007-11-22 3:32 UTC (permalink / raw)
To: Shi Weihua; +Cc: linux-kernel, tony.luck, linux-ia64
On Thu, Nov 22, 2007 at 11:15:55AM +0800, Shi Weihua wrote:
> This patch removes some redundant code in the function setup_sigcontext().
>
> The registers ar.ccv,b7,r14,ar.csd,ar.ssd,r2-r3 and r16-r31 are not restored
> in restore_sigcontext() when (flags & IA64_SC_FLAG_IN_SYSCALL) is true.
> So we don't need to zero those variables in setup_sigcontext().
Erm, couldn't those registers contain information the process shouldn't
see?
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH RFC][try 2] IA64 signal : remove redundant code in setup_sigcontext()
2007-11-22 3:32 ` Matthew Wilcox
@ 2007-12-18 23:29 ` Luck, Tony
0 siblings, 0 replies; 3+ messages in thread
From: Luck, Tony @ 2007-12-18 23:29 UTC (permalink / raw)
To: Matthew Wilcox, Shi Weihua; +Cc: linux-kernel, linux-ia64
>> This patch removes some redundant code in the function setup_sigcontext().
>>
>> The registers ar.ccv,b7,r14,ar.csd,ar.ssd,r2-r3 and r16-r31 are not restored
>> in restore_sigcontext() when (flags & IA64_SC_FLAG_IN_SYSCALL) is true.
>> So we don't need to zero those variables in setup_sigcontext().
>
> Erm, couldn't those registers contain information the process shouldn't
> see?
No, this looks safe. setup_sigcontext() is stashing things out on the
user stack to be used by restore_sigcontext() should the application want
to return from the signal handler. But restore_sigcontext isn't actually
in charge of putting values into machine registers, it just does the copy
back from user space to the place where the asm code will restore registers
on the way back to userland. In this instance "restored" means "set back to
the state they had before the signal happened". If they aren't "restored"
they'll have scratch values ... but those scratch values will have come
from the application (while it was executing the signal handler). Not
leaked from the kernel or from some other application.
-Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-18 23:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-22 3:15 [PATCH RFC][try 2] IA64 signal : remove redundant code in setup_sigcontext() Shi Weihua
2007-11-22 3:32 ` Matthew Wilcox
2007-12-18 23:29 ` Luck, Tony
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox