svn commit: trunk/uClibc/libc/sysdeps/linux/i386

aldot at uclibc.org aldot at uclibc.org
Sun Oct 19 13:27:09 UTC 2008


Author: aldot
Date: 2008-10-19 06:27:09 -0700 (Sun, 19 Oct 2008)
New Revision: 23720

Log:
- fix sigaction on older kernels (Michael Deutschmann)
  In issue #5554 Michael wrote:
The implementation of sigaction on i386 for older kernels makes the system call using an inline asm element with two flaws:

1. The asm is not marked as depending on the kact structure or modifying the koact structure. Thus, GCC is free to assume these structures need not be kept consistent, allowing it to remove all initialization of kact.

2. The asm allows the signal number to be provided as a memory reference. But this allows GCC to provide a stack-relative operand, which will break because the assembler saves %ebx on the stack before using that operand.

1 didn't use to be a problem in practice because GCC 4.2.* didn't seize the optimization opportunity. GCC 4.3.2, however, optimizes out the "kact.sa_flags = act->sa_flags | SA_RESTORER;" line, so that the kernel sees garbage in sa_flags. This can result in the kernel seeing the SA_RESETHAND flag, causing erratic behaviour in signal dependent programs.

2 becomes an issue if "-fomit-frame-pointer" is provided. In uClibc-0.9.29 it isn't, uClibc-0.9.30-rc2 does use the flag by default.



Modified:
   trunk/uClibc/libc/sysdeps/linux/i386/sigaction.c


Changeset:
Modified: trunk/uClibc/libc/sysdeps/linux/i386/sigaction.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/i386/sigaction.c	2008-10-19 07:59:19 UTC (rev 23719)
+++ trunk/uClibc/libc/sysdeps/linux/i386/sigaction.c	2008-10-19 13:27:09 UTC (rev 23720)
@@ -99,11 +99,11 @@
     }
 
     __asm__ __volatile__ ("pushl %%ebx\n"
-	    "movl %2, %%ebx\n"
+	    "movl %3, %%ebx\n"
 	    "int $0x80\n"
 	    "popl %%ebx"
-	    : "=a" (result)
-	    : "0" (__NR_sigaction), "mr" (sig),
+	    : "=a" (result), "=m" (koact)
+	    : "0" (__NR_sigaction), "r" (sig), "m" (kact),
 	    "c" (act ? __ptrvalue (&kact) : 0),
 	    "d" (oact ? __ptrvalue (&koact) : 0));
 




More information about the uClibc-cvs mailing list