summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2002-02-03 09:13:58 +0000
committerbde <bde@FreeBSD.org>2002-02-03 09:13:58 +0000
commit02ad3c7acac134e55beffbe42c345bc6f4b19d09 (patch)
tree5b287d6f54543df4565e79db5ade17a30aa455b6 /sys
parentc41b30278b448bd9b788cceefb4d33e5084e52f8 (diff)
downloadFreeBSD-src-02ad3c7acac134e55beffbe42c345bc6f4b19d09.zip
FreeBSD-src-02ad3c7acac134e55beffbe42c345bc6f4b19d09.tar.gz
Use osigreturn(2) instead of sigreturn(2) plus broken magic for returning
from old signal handlers. This is simpler and faster, and fixes (new) sigreturn(2) when %eip in the new signal context happens to match the magic value (0x1d516). 0x1d516 is below the default ELF text section, so this probably never broken anything in practice. locore.s: In addition, don't build the signal trampoline for old signal handlers when it is not used. alpha: Not fixed, but seems to be even less broken in practice due to more advanced magic. A false match occurs for register #32 in mc_regs[]. Since there is no hardware register #32, a false match is only possible for direct calls to sigreturn(2) that happen to have the magic number in the spare mc_regs[32] field.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/locore.S8
-rw-r--r--sys/amd64/amd64/locore.s8
-rw-r--r--sys/amd64/amd64/machdep.c9
-rw-r--r--sys/i386/i386/locore.s8
-rw-r--r--sys/i386/i386/machdep.c9
-rw-r--r--sys/pc98/i386/machdep.c9
-rw-r--r--sys/pc98/pc98/machdep.c9
7 files changed, 18 insertions, 42 deletions
diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S
index ab3dad5..4fff220 100644
--- a/sys/amd64/amd64/locore.S
+++ b/sys/amd64/amd64/locore.S
@@ -44,6 +44,7 @@
*/
#include "opt_bootp.h"
+#include "opt_compat.h"
#include "opt_nfsroot.h"
#include <sys/syscall.h>
@@ -416,6 +417,7 @@ NON_GPROF_ENTRY(sigcode)
int $0x80 /* enter kernel with args */
0: jmp 0b
+#ifdef COMPAT_43
ALIGN_TEXT
osigcode:
call *SIGF_HANDLER(%esp) /* call signal handler */
@@ -425,11 +427,11 @@ osigcode:
jne 9f
movl SC_GS(%eax),%gs /* restore %gs */
9:
- movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
- movl $SYS_sigreturn,%eax
+ movl $SYS_osigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
0: jmp 0b
+#endif /* COMPAT_43 */
ALIGN_TEXT
esigcode:
@@ -438,8 +440,10 @@ esigcode:
.globl szsigcode, szosigcode
szsigcode:
.long esigcode-sigcode
+#ifdef COMPAT_43
szosigcode:
.long esigcode-osigcode
+#endif
.text
/**********************************************************************
diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s
index ab3dad5..4fff220 100644
--- a/sys/amd64/amd64/locore.s
+++ b/sys/amd64/amd64/locore.s
@@ -44,6 +44,7 @@
*/
#include "opt_bootp.h"
+#include "opt_compat.h"
#include "opt_nfsroot.h"
#include <sys/syscall.h>
@@ -416,6 +417,7 @@ NON_GPROF_ENTRY(sigcode)
int $0x80 /* enter kernel with args */
0: jmp 0b
+#ifdef COMPAT_43
ALIGN_TEXT
osigcode:
call *SIGF_HANDLER(%esp) /* call signal handler */
@@ -425,11 +427,11 @@ osigcode:
jne 9f
movl SC_GS(%eax),%gs /* restore %gs */
9:
- movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
- movl $SYS_sigreturn,%eax
+ movl $SYS_osigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
0: jmp 0b
+#endif /* COMPAT_43 */
ALIGN_TEXT
esigcode:
@@ -438,8 +440,10 @@ esigcode:
.globl szsigcode, szosigcode
szsigcode:
.long esigcode-sigcode
+#ifdef COMPAT_43
szosigcode:
.long esigcode-osigcode
+#endif
.text
/**********************************************************************
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 308d319..13e8b0a 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -710,19 +710,10 @@ sigreturn(td, uap)
} */ *uap;
{
struct proc *p = td->td_proc;
- struct osigcontext *oscp;
- struct osigreturn_args *ouap;
struct trapframe *regs;
ucontext_t *ucp;
int cs, eflags;
-#ifdef COMPAT_43
- ouap = (struct osigreturn_args *)uap;
- oscp = ouap->sigcntxp;
- if (fuword(&oscp->sc_trapno) == 0x01d516)
- return (osigreturn(td, ouap));
-#endif
-
ucp = uap->sigcntxp;
if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ))
return (EFAULT);
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index ab3dad5..4fff220 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -44,6 +44,7 @@
*/
#include "opt_bootp.h"
+#include "opt_compat.h"
#include "opt_nfsroot.h"
#include <sys/syscall.h>
@@ -416,6 +417,7 @@ NON_GPROF_ENTRY(sigcode)
int $0x80 /* enter kernel with args */
0: jmp 0b
+#ifdef COMPAT_43
ALIGN_TEXT
osigcode:
call *SIGF_HANDLER(%esp) /* call signal handler */
@@ -425,11 +427,11 @@ osigcode:
jne 9f
movl SC_GS(%eax),%gs /* restore %gs */
9:
- movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
- movl $SYS_sigreturn,%eax
+ movl $SYS_osigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
0: jmp 0b
+#endif /* COMPAT_43 */
ALIGN_TEXT
esigcode:
@@ -438,8 +440,10 @@ esigcode:
.globl szsigcode, szosigcode
szsigcode:
.long esigcode-sigcode
+#ifdef COMPAT_43
szosigcode:
.long esigcode-osigcode
+#endif
.text
/**********************************************************************
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 308d319..13e8b0a 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -710,19 +710,10 @@ sigreturn(td, uap)
} */ *uap;
{
struct proc *p = td->td_proc;
- struct osigcontext *oscp;
- struct osigreturn_args *ouap;
struct trapframe *regs;
ucontext_t *ucp;
int cs, eflags;
-#ifdef COMPAT_43
- ouap = (struct osigreturn_args *)uap;
- oscp = ouap->sigcntxp;
- if (fuword(&oscp->sc_trapno) == 0x01d516)
- return (osigreturn(td, ouap));
-#endif
-
ucp = uap->sigcntxp;
if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ))
return (EFAULT);
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index 0c0243d..71d2098 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -723,19 +723,10 @@ sigreturn(td, uap)
} */ *uap;
{
struct proc *p = td->td_proc;
- struct osigcontext *oscp;
- struct osigreturn_args *ouap;
struct trapframe *regs;
ucontext_t *ucp;
int cs, eflags;
-#ifdef COMPAT_43
- ouap = (struct osigreturn_args *)uap;
- oscp = ouap->sigcntxp;
- if (fuword(&oscp->sc_trapno) == 0x01d516)
- return (osigreturn(td, ouap));
-#endif
-
ucp = uap->sigcntxp;
if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ))
return (EFAULT);
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 0c0243d..71d2098 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -723,19 +723,10 @@ sigreturn(td, uap)
} */ *uap;
{
struct proc *p = td->td_proc;
- struct osigcontext *oscp;
- struct osigreturn_args *ouap;
struct trapframe *regs;
ucontext_t *ucp;
int cs, eflags;
-#ifdef COMPAT_43
- ouap = (struct osigreturn_args *)uap;
- oscp = ouap->sigcntxp;
- if (fuword(&oscp->sc_trapno) == 0x01d516)
- return (osigreturn(td, ouap));
-#endif
-
ucp = uap->sigcntxp;
if (!useracc((caddr_t)ucp, sizeof(*ucp), VM_PROT_READ))
return (EFAULT);
OpenPOWER on IntegriCloud