Re: [PATCH] PPC32: cancel syscall restart on signal delivery

From: Paul Mackerras
Date: Sat Nov 15 2003 - 01:26:07 EST


Linus Torvalds writes:

> Excellent point. We're actually much better off resetting it at signal
> return.
>
> Which should make all other resets unnecessary.

Yes.

> Yes, you can get out of a signal by using longjmp, but that doesn't
> matter: you can't longjump to a restart call (well, you can, but only if
> the user literally tries to do the restart by hand, ie he _intended_ to do
> it).
>
> So the _proper_ fix (for x86) should be as appended. Agreed?

Agreed. Here is the patch for PPC.

Thanks,
Paul.

diff -urN linux-2.5/arch/ppc/kernel/signal.c pmac-2.5/arch/ppc/kernel/signal.c
--- linux-2.5/arch/ppc/kernel/signal.c 2003-11-15 16:55:18.618797320 +1100
+++ pmac-2.5/arch/ppc/kernel/signal.c 2003-11-15 17:09:53.145849000 +1100
@@ -418,6 +418,9 @@
{
struct rt_sigframe __user *rt_sf;

+ /* Always make any pending restarted system calls return -EINTR */
+ current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
rt_sf = (struct rt_sigframe __user *)
(regs->gpr[1] + __SIGNAL_FRAMESIZE + 16);
if (verify_area(VERIFY_READ, rt_sf, sizeof(struct rt_sigframe)))
@@ -513,6 +516,9 @@
struct mcontext __user *sr;
sigset_t set;

+ /* Always make any pending restarted system calls return -EINTR */
+ current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
sc = (struct sigcontext __user *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
goto badframe;
@@ -583,9 +589,6 @@
if (signr == 0)
return 0; /* no signals delivered */

- /* Always make any pending restarted system calls return -EINTR */
- current_thread_info()->restart_block.fn = do_no_restart_syscall;
-
if ((ka->sa.sa_flags & SA_ONSTACK) && current->sas_ss_size
&& !on_sig_stack(regs->gpr[1]))
newsp = current->sas_ss_sp + current->sas_ss_size;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/