]> git.neil.brown.name Git - history.git/commit
[PATCH] ppc64: fix incorrect signal handler argument
authorPaul Mackerras <paulus@samba.org>
Sat, 1 May 2004 12:10:20 +0000 (05:10 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 1 May 2004 12:10:20 +0000 (05:10 -0700)
commit661c8e51951712b193aab3b189f9f2cb00d27fad
treee813b7c890d1872e2ef5c07388699e938b9846f6
parent1f3c42cc0d3a10712fd7bf6a3284af034a40ec92
[PATCH] ppc64: fix incorrect signal handler argument

This fixes a bug in the ppc64 signal delivery code where the signal
number argument to a signal handler can get corrupted before the handler
is called.  The specific scenario is that a process is in a blocking
system call when two signals get generated for it, both of which have
handlers.

The signal code will stack up two signal frames on the process stack
(assuming the mask for the first signal delivered doesn't block the
second signal) and return to userspace to run the handler for the second
signal.  On return from that handler the first handler gets run with an
incorrect signal number argument because we end up with regs->result
still having a negative value (left over from when the system call was
interrupted) when it should be zero.  This patch sets it to zero when we
set up the signal frame (in three places; for 64-bit processes, and for
32-bit processes for RT and non-RT signals).

The way we handle signal delivery and signal handler return using the
regs->result field in ppc64 is more complicated than it needs to be.  In
ppc32 I have already simplified it and eliminated use of the
regs->result field.  I am going to do the same in the ppc64 code, but I
think this patch should go in for now to fix the bug.

The patch also fixes a couple of places where we were unnecessarily and
incorrectly truncating the regs->result value to 32 bits
(sys32_sigreturn and sys32_rt_sigreturn return a long value, as all
syscalls do, and if regs->result is negative we need those syscalls to
return a negative value).

Thanks to Maneesh Soni for identifying the specific circumstances
under which this bug shows up.
arch/ppc64/kernel/signal.c
arch/ppc64/kernel/signal32.c