summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-10-06 15:46:04 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-10-06 15:46:04 +0000
commit8be5040a6e8f33ead729a23c891aded656391565 (patch)
tree0370a7e22e0aad48f2d65220c475558cec02da2e /sys
parent790b950f10287934fe7b470dd399f607713d930e (diff)
Change sendsig() interface so that the MD code does not need to access
data from struct process anymore. This changes how siginfo and onstack are accessed and make sendsig() more MP friendly. With and OK semarie@ OK kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/machdep.c13
-rw-r--r--sys/arch/amd64/amd64/machdep.c10
-rw-r--r--sys/arch/arm/arm/sig_machdep.c10
-rw-r--r--sys/arch/arm64/arm64/sig_machdep.c10
-rw-r--r--sys/arch/hppa/hppa/machdep.c10
-rw-r--r--sys/arch/i386/i386/machdep.c10
-rw-r--r--sys/arch/m88k/m88k/sig_machdep.c14
-rw-r--r--sys/arch/macppc/macppc/machdep.c12
-rw-r--r--sys/arch/mips64/mips64/sendsig.c14
-rw-r--r--sys/arch/powerpc64/powerpc64/machdep.c10
-rw-r--r--sys/arch/riscv64/riscv64/sig_machdep.c10
-rw-r--r--sys/arch/sh/sh/sh_machdep.c10
-rw-r--r--sys/arch/sparc64/sparc64/machdep.c10
-rw-r--r--sys/kern/kern_sig.c14
-rw-r--r--sys/sys/signalvar.h5
15 files changed, 85 insertions, 77 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index ca164c6acf0..d1f7709a84a 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.195 2020/11/08 20:37:21 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.196 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
@@ -1384,13 +1384,13 @@ regdump(framep)
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct sigcontext ksc, *scp;
struct fpreg *fpregs = (struct fpreg *)&ksc.sc_fpregs;
struct trapframe *frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
unsigned long oldsp;
int fsize, rndfsize, kscsize;
siginfo_t *sip;
@@ -1400,7 +1400,8 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
fsize = sizeof ksc;
rndfsize = ((fsize + 15) / 16) * 16;
kscsize = rndfsize;
- if (psp->ps_siginfo & sigmask(sig)) {
+
+ if (info) {
fsize += sizeof *ksip;
rndfsize = ((fsize + 15) / 16) * 16;
}
@@ -1409,7 +1410,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Allocate space for the signal handler context.
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(oldsp) && onstack)
scp = (struct sigcontext *)
(trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size)
- rndfsize);
@@ -1442,7 +1443,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
memset(ksc.sc_reserved, 0, sizeof ksc.sc_reserved); /* XXX */
memset(ksc.sc_xxx, 0, sizeof ksc.sc_xxx); /* XXX */
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = (void *)scp + kscsize;
if (copyout(ksip, (caddr_t)sip, fsize - kscsize) != 0)
return 1;
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index a8edb52bde0..326f1c10253 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.274 2021/05/01 16:18:28 gnezdo Exp $ */
+/* $OpenBSD: machdep.c,v 1.275 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -564,11 +564,11 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
* user specified pc.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf = p->p_md.md_regs;
- struct sigacts *psp = p->p_p->ps_sigacts;
struct sigcontext ksc;
struct savefpu *sfp = &p->p_addr->u_pcb.pcb_savefpu;
register_t sp, scp, sip;
@@ -599,7 +599,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
/* Allocate space for the signal handler context. */
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_rsp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_rsp) && onstack)
sp = trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
sp = tf->tf_rsp - 128;
@@ -622,7 +622,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
&proc0.p_addr->u_pcb.pcb_savefpu, fpu_save_len);
sip = 0;
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = sp - ((sizeof(*ksip) + 15) & ~15);
sss += (sizeof(*ksip) + 15) & ~15;
diff --git a/sys/arch/arm/arm/sig_machdep.c b/sys/arch/arm/arm/sig_machdep.c
index 27a44e00f07..71022a05931 100644
--- a/sys/arch/arm/arm/sig_machdep.c
+++ b/sys/arch/arm/arm/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.20 2021/03/25 04:12:00 jsg Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.21 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $ */
/*
@@ -74,19 +74,19 @@ process_frame(struct proc *p)
* user specified pc.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
tf = process_frame(p);
/* Allocate space for the signal handler context. */
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_usr_sp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_usr_sp) && onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -138,7 +138,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
pcb->pcb_fpcpu = NULL;
}
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
frame.sf_sip = &fp->sf_si;
frame.sf_si = *ksip;
}
diff --git a/sys/arch/arm64/arm64/sig_machdep.c b/sys/arch/arm64/arm64/sig_machdep.c
index b776ae4adc2..69006f72827 100644
--- a/sys/arch/arm64/arm64/sig_machdep.c
+++ b/sys/arch/arm64/arm64/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.7 2020/11/08 20:37:22 mpi Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.8 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -95,12 +95,12 @@ process_frame(struct proc *p)
* user specified pc.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
siginfo_t *sip = NULL;
int i;
@@ -108,7 +108,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
/* Allocate space for the signal handler context. */
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_sp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_sp) && onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -137,7 +137,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
/* XXX Save floating point context */
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = &fp->sf_si;
frame.sf_si = *ksip;
}
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index fa373acfc3e..3536d5dcf19 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.264 2021/03/11 11:16:56 jsg Exp $ */
+/* $OpenBSD: machdep.c,v 1.265 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1206,12 +1206,12 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
- struct sigacts *psp = p->p_p->ps_sigacts;
struct sigcontext ksc;
register_t scp, sip;
int sss;
@@ -1223,14 +1223,14 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Allocate space for the signal handler context.
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_sp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_sp) && onstack)
scp = round_page((vaddr_t)p->p_sigstk.ss_sp);
else
scp = (tf->tf_sp + 63) & ~63;
sss = (sizeof(ksc) + 63) & ~63;
sip = 0;
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = scp + sizeof(ksc);
sss += (sizeof(*ksip) + 63) & ~63;
}
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 5180762983d..0d32cd4edd7 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.645 2021/05/01 16:18:28 gnezdo Exp $ */
+/* $OpenBSD: machdep.c,v 1.646 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -2444,12 +2444,12 @@ pentium_cpuspeed(int *freq)
* specified pc, psl.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf = p->p_md.md_regs;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
register_t sp;
/*
@@ -2462,7 +2462,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Allocate space for the signal handler context.
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_esp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_esp) && onstack)
sp = trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
sp = tf->tf_esp;
@@ -2509,7 +2509,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
frame.sf_sc.sc_esp = tf->tf_esp;
frame.sf_sc.sc_ss = tf->tf_ss;
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
frame.sf_sip = &fp->sf_si;
frame.sf_si = *ksip;
}
diff --git a/sys/arch/m88k/m88k/sig_machdep.c b/sys/arch/m88k/m88k/sig_machdep.c
index cf4e731093d..2c46f4687f4 100644
--- a/sys/arch/m88k/m88k/sig_machdep.c
+++ b/sys/arch/m88k/m88k/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.30 2020/11/08 20:37:23 mpi Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.31 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 2014 Miodrag Vallat.
*
@@ -104,11 +104,11 @@ pid_t sigpid = 0;
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf;
- struct sigacts *psp = p->p_p->ps_sigacts;
struct sigframe *fp;
size_t fsize;
struct sigframe sf;
@@ -116,7 +116,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
tf = p->p_md.md_tf;
- if (psp->ps_siginfo & sigmask(sig))
+ if (info)
fsize = sizeof(struct sigframe);
else
fsize = offsetof(struct sigframe, sf_si);
@@ -125,7 +125,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Allocate space for the signal handler context.
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_r[31]) && (psp->ps_sigonstack & sigmask(sig))) {
+ !sigonstack(tf->tf_r[31]) && onstack) {
addr = local_stack_frame(tf,
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size),
fsize);
@@ -142,7 +142,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
sf.sf_sc.sc_mask = mask;
sf.sf_sc.sc_cookie = (long)sf.sf_scp ^ p->p_p->ps_sigcookie;
- if (psp->ps_siginfo & sigmask(sig))
+ if (info)
sf.sf_si = *ksip;
/*
@@ -160,7 +160,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
*/
tf->tf_r[1] = p->p_p->ps_sigcode; /* return to sigcode */
tf->tf_r[2] = sig; /* first arg is signo */
- tf->tf_r[3] = psp->ps_siginfo & sigmask(sig) ? (vaddr_t)&fp->sf_si : 0;
+ tf->tf_r[3] = info ? (vaddr_t)&fp->sf_si : 0;
tf->tf_r[4] = (vaddr_t)&fp->sf_sc;
tf->tf_r[31] = (vaddr_t)fp;
addr = (vaddr_t)catcher; /* and resume in the handler */
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index c3347da0b96..2014c70ed84 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.193 2020/11/08 20:37:23 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.194 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -443,12 +443,12 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
* Send a signal to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
bzero(&frame, sizeof(frame));
frame.sf_signum = sig;
@@ -460,7 +460,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
!sigonstack(tf->fixreg[1]) &&
- (psp->ps_sigonstack & sigmask(sig)))
+ onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -474,7 +474,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
frame.sf_sc.sc_mask = mask;
frame.sf_sip = NULL;
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
frame.sf_sip = &fp->sf_si;
frame.sf_si = *ksip;
}
@@ -485,7 +485,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
tf->fixreg[1] = (int)fp;
tf->lr = (int)catcher;
tf->fixreg[3] = (int)sig;
- tf->fixreg[4] = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : 0;
+ tf->fixreg[4] = info ? (int)&fp->sf_si : 0;
tf->fixreg[5] = (int)&fp->sf_sc;
tf->srr0 = p->p_p->ps_sigcode;
diff --git a/sys/arch/mips64/mips64/sendsig.c b/sys/arch/mips64/mips64/sendsig.c
index 8d4de5df441..0f07636594f 100644
--- a/sys/arch/mips64/mips64/sendsig.c
+++ b/sys/arch/mips64/mips64/sendsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendsig.c,v 1.34 2020/11/08 20:37:23 mpi Exp $ */
+/* $OpenBSD: sendsig.c,v 1.35 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -92,13 +92,13 @@ struct sigframe {
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct cpu_info *ci = curcpu();
struct proc *p = ci->ci_curproc;
struct sigframe *fp;
struct trapframe *regs;
- struct sigacts *psp = p->p_p->ps_sigacts;
int fsize;
struct sigcontext ksc;
@@ -108,10 +108,10 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Allocate space for the signal handler context.
*/
fsize = sizeof(struct sigframe);
- if (!(psp->ps_siginfo & sigmask(sig)))
+ if (!info)
fsize -= sizeof(siginfo_t);
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(regs->sp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(regs->sp) && onstack)
fp = (struct sigframe *)
(trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size)
- fsize);
@@ -137,7 +137,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
sizeof(ksc.sc_fpregs));
}
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
if (copyout(ksip, (caddr_t)&fp->sf_si, sizeof *ksip))
return 1;
}
@@ -150,7 +150,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* Build the argument list for the signal handler.
*/
regs->a0 = sig;
- regs->a1 = (psp->ps_siginfo & sigmask(sig)) ? (register_t)&fp->sf_si : 0;
+ regs->a1 = info ? (register_t)&fp->sf_si : 0;
regs->a2 = (register_t)&fp->sf_sc;
regs->a3 = (register_t)catcher;
diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c
index 3a7bcd53301..9629cb0eda0 100644
--- a/sys/arch/powerpc64/powerpc64/machdep.c
+++ b/sys/arch/powerpc64/powerpc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.69 2021/05/13 22:42:14 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.70 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -911,19 +911,19 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
}
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct pcb *pcb = &p->p_addr->u_pcb;
struct trapframe *tf = p->p_md.md_regs;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
siginfo_t *sip = NULL;
int i;
/* Allocate space for the signal handler context. */
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->fixreg[1]) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->fixreg[1]) && onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -964,7 +964,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
/* Save signal mask. */
frame.sf_sc.sc_mask = mask;
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = &fp->sf_si;
frame.sf_si = *ksip;
}
diff --git a/sys/arch/riscv64/riscv64/sig_machdep.c b/sys/arch/riscv64/riscv64/sig_machdep.c
index cb6f1153db5..db0e36cc192 100644
--- a/sys/arch/riscv64/riscv64/sig_machdep.c
+++ b/sys/arch/riscv64/riscv64/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.8 2021/06/30 22:20:56 kettenis Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.9 2021/10/06 15:46:03 claudio Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -111,12 +111,12 @@ void dumpframe (char *msg, struct trapframe *tf, void *p)
* user specified pc.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct trapframe *tf;
struct sigframe *fp, frame;
- struct sigacts *psp = p->p_p->ps_sigacts;
struct fpreg *fpreg;
siginfo_t *sip = NULL;
int i;
@@ -125,7 +125,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
/* Allocate space for the signal handler context. */
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(tf->tf_sp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(tf->tf_sp) && onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -168,7 +168,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
frame.sf_sc.sc_fcsr = fpreg->fp_fcsr;
}
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sip = &fp->sf_si;
frame.sf_si = *ksip;
}
diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c
index 7e4b1703104..3d321768324 100644
--- a/sys/arch/sh/sh/sh_machdep.c
+++ b/sys/arch/sh/sh/sh_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh_machdep.c,v 1.52 2020/11/08 20:37:23 mpi Exp $ */
+/* $OpenBSD: sh_machdep.c,v 1.53 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */
/*
@@ -447,17 +447,17 @@ struct sigframe {
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
struct sigframe *fp, frame;
struct trapframe *tf = p->p_md.md_regs;
- struct sigacts *psp = p->p_p->ps_sigacts;
siginfo_t *sip;
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
!sigonstack(p->p_md.md_regs->tf_r15) &&
- (psp->ps_sigonstack & sigmask(sig)))
+ onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -467,7 +467,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
bzero(&frame, sizeof(frame));
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
frame.sf_si = *ksip;
sip = &fp->sf_si;
} else
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c
index fb6cff2f1a2..2c7e3cd406e 100644
--- a/sys/arch/sparc64/sparc64/machdep.c
+++ b/sys/arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.199 2020/11/08 20:37:24 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.200 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
@@ -403,10 +403,10 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
* Send an interrupt to process.
*/
int
-sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
+sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
+ int info, int onstack)
{
struct proc *p = curproc;
- struct sigacts *psp = p->p_p->ps_sigacts;
struct sigframe *fp;
struct trapframe64 *tf;
vaddr_t addr, oldsp, newsp;
@@ -420,7 +420,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
* one signal frame, and align.
*/
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
+ !sigonstack(oldsp) && onstack)
fp = (struct sigframe *)
trunc_page((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
@@ -449,7 +449,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip)
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
- if (psp->ps_siginfo & sigmask(sig)) {
+ if (info) {
sf.sf_sip = &fp->sf_si;
sf.sf_si = *ksip;
}
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 4a76f751b36..83d183aed8d 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.284 2021/10/04 08:48:12 claudio Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.285 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -819,6 +819,9 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
(ps->ps_sigcatch & mask) != 0 &&
(p->p_sigmask & mask) == 0) {
siginfo_t si;
+ int info = (ps->ps_siginfo & mask) != 0;
+ int onstack = (ps->ps_sigonstack & mask) != 0;
+
initsiginfo(&si, signum, trapno, code, sigval);
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG)) {
@@ -826,7 +829,8 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
p->p_sigmask, code, &si);
}
#endif
- if (sendsig(ps->ps_sigact[signum], signum, p->p_sigmask, &si)) {
+ if (sendsig(ps->ps_sigact[signum], signum, p->p_sigmask, &si,
+ info, onstack)) {
sigexit(p, SIGILL);
/* NOTREACHED */
}
@@ -1396,7 +1400,7 @@ postsig(struct proc *p, int signum)
int mask, returnmask;
siginfo_t si;
union sigval sigval;
- int s, code;
+ int s, code, info, onstack;
KASSERT(signum != 0);
KERNEL_ASSERT_LOCKED();
@@ -1404,6 +1408,8 @@ postsig(struct proc *p, int signum)
mask = sigmask(signum);
atomic_clearbits_int(&p->p_siglist, mask);
action = ps->ps_sigact[signum];
+ info = (ps->ps_siginfo & mask) != 0;
+ onstack = (ps->ps_sigonstack & mask) != 0;
sigval.sival_ptr = 0;
if (p->p_sisig != signum) {
@@ -1465,7 +1471,7 @@ postsig(struct proc *p, int signum)
p->p_sigval.sival_ptr = NULL;
}
- if (sendsig(action, signum, returnmask, &si)) {
+ if (sendsig(action, signum, returnmask, &si, info, onstack)) {
sigexit(p, SIGILL);
/* NOTREACHED */
}
diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h
index 6fb4c8f9e6c..5157448210a 100644
--- a/sys/sys/signalvar.h
+++ b/sys/sys/signalvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signalvar.h,v 1.49 2021/10/05 08:38:19 claudio Exp $ */
+/* $OpenBSD: signalvar.h,v 1.50 2021/10/06 15:46:03 claudio Exp $ */
/* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */
/*
@@ -120,6 +120,7 @@ void sigactsfree(struct process *);
/*
* Machine-dependent functions:
*/
-int sendsig(sig_t _catcher, int _sig, sigset_t _mask, const siginfo_t *_si);
+int sendsig(sig_t _catcher, int _sig, sigset_t _mask, const siginfo_t *_si,
+ int _info, int _onstack);
#endif /* _KERNEL */
#endif /* !_SYS_SIGNALVAR_H_ */