fix signal return for sh/fdpic
authorRich Felker <dalias@aerifal.cx>
Wed, 23 Sep 2015 18:33:49 +0000 (18:33 +0000)
committerRich Felker <dalias@aerifal.cx>
Wed, 23 Sep 2015 18:33:49 +0000 (18:33 +0000)
the restorer function pointer provided in the kernel sigaction
structure is interpreted by the kernel as a raw code address, not a
function descriptor.

this commit moves the declarations of the __restore and __restore_rt
symbols to ksigaction.h so that arch versions of the file can override
them, and introduces a version for sh which declares them as objects
rather than functions.

an alternate solution would have been defining SA_RESTORER to 0 so
that the functions are not used, but this both requires executable
stack (since the sh kernel does not have a vdso page with permanent
restorer functions) and crashes on qemu user-level emulation.

arch/mips/ksigaction.h
arch/sh/ksigaction.h [new file with mode: 0644]
src/internal/ksigaction.h
src/signal/sh/restore.s
src/signal/sigaction.c

index 6d73164..3127f7c 100644 (file)
@@ -7,3 +7,5 @@ struct k_sigaction {
         * mips-specific preprocessor conditionals in sigaction.c. */
        void (*restorer)();
 };
+
+void __restore(), __restore_rt();
diff --git a/arch/sh/ksigaction.h b/arch/sh/ksigaction.h
new file mode 100644 (file)
index 0000000..0c652be
--- /dev/null
@@ -0,0 +1,8 @@
+struct k_sigaction {
+       void (*handler)(int);
+       unsigned long flags;
+       void *restorer;
+       unsigned mask[2];
+};
+
+extern unsigned char __restore[], __restore_rt[];
index 2eacabf..1d8d964 100644 (file)
@@ -7,3 +7,5 @@ struct k_sigaction {
        void (*restorer)(void);
        unsigned mask[2];
 };
+
+void __restore(), __restore_rt();
index eaedcdf..d5df8e1 100644 (file)
@@ -1,5 +1,4 @@
 .global __restore
-.type   __restore, @function
 __restore:
        mov   #119, r3  !__NR_sigreturn
        trapa #31
@@ -11,7 +10,6 @@ __restore:
        or    r0, r0
 
 .global __restore_rt
-.type   __restore_rt, @function
 __restore_rt:
        mov   #100, r3  !__NR_rt_sigreturn
        add   #73, r3
index d5f4774..ab23a6f 100644 (file)
@@ -6,8 +6,6 @@
 #include "libc.h"
 #include "ksigaction.h"
 
-void __restore(), __restore_rt();
-
 static int unmask_done;
 static unsigned long handler_set[_NSIG/(8*sizeof(long))];