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.
This commit is contained in:
bde 2002-02-03 09:13:58 +00:00
parent c41b30278b
commit 02ad3c7aca
7 changed files with 18 additions and 42 deletions

View File

@ -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
/**********************************************************************

View File

@ -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
/**********************************************************************

View File

@ -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);

View File

@ -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
/**********************************************************************

View File

@ -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);

View File

@ -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);

View File

@ -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);