History log of /openbsd-current/sys/arch/arm/arm/sig_machdep.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.21 06-Oct-2021 claudio

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@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.20 25-Mar-2021 jsg

remove uneeded includes in md armv7 files

based on include-what-you-use suggestions


# 1.19 08-Nov-2020 mpi

In case of failure, call sigexit() from trapsignal instead of sensig().

Simplify MD code and reduce the amount of recursion into the signal code
which helps when dealing with locks.

ok cheloha@, deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.18 10-Jul-2018 guenther

Move from sendsig() to its callers the initsiginfo() calls and
instead of passing sendsig() the code+type+val, pass a siginfo_t*
to copy from. Eliminate the indirection through struct emul for
sendsig(); we no longer have a SunOS4-compat version of sendsig()

ok deraadt@


# 1.17 23-Jun-2018 kettenis

Save and restore FPU registers around signal handlers.
Fixes the random crashes in sh(1).

ok guenther@


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


# 1.20 25-Mar-2021 jsg

remove uneeded includes in md armv7 files

based on include-what-you-use suggestions


# 1.19 08-Nov-2020 mpi

In case of failure, call sigexit() from trapsignal instead of sensig().

Simplify MD code and reduce the amount of recursion into the signal code
which helps when dealing with locks.

ok cheloha@, deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.18 10-Jul-2018 guenther

Move from sendsig() to its callers the initsiginfo() calls and
instead of passing sendsig() the code+type+val, pass a siginfo_t*
to copy from. Eliminate the indirection through struct emul for
sendsig(); we no longer have a SunOS4-compat version of sendsig()

ok deraadt@


# 1.17 23-Jun-2018 kettenis

Save and restore FPU registers around signal handlers.
Fixes the random crashes in sh(1).

ok guenther@


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


# 1.19 08-Nov-2020 mpi

In case of failure, call sigexit() from trapsignal instead of sensig().

Simplify MD code and reduce the amount of recursion into the signal code
which helps when dealing with locks.

ok cheloha@, deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.18 10-Jul-2018 guenther

Move from sendsig() to its callers the initsiginfo() calls and
instead of passing sendsig() the code+type+val, pass a siginfo_t*
to copy from. Eliminate the indirection through struct emul for
sendsig(); we no longer have a SunOS4-compat version of sendsig()

ok deraadt@


# 1.17 23-Jun-2018 kettenis

Save and restore FPU registers around signal handlers.
Fixes the random crashes in sh(1).

ok guenther@


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


# 1.18 10-Jul-2018 guenther

Move from sendsig() to its callers the initsiginfo() calls and
instead of passing sendsig() the code+type+val, pass a siginfo_t*
to copy from. Eliminate the indirection through struct emul for
sendsig(); we no longer have a SunOS4-compat version of sendsig()

ok deraadt@


# 1.17 23-Jun-2018 kettenis

Save and restore FPU registers around signal handlers.
Fixes the random crashes in sh(1).

ok guenther@


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


# 1.17 23-Jun-2018 kettenis

Save and restore FPU registers around signal handlers.
Fixes the random crashes in sh(1).

ok guenther@


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


# 1.16 12-Apr-2018 deraadt

Implement MAP_STACK option for mmap(). Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.15 12-Mar-2017 kettenis

Bring SROP mitigation to arm64. Make some small modifications to the arm
code as well to improve diffability. Changes the types used in the arm64
"struct sigcontext" to avoid having to include <sys/types.h>.

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.14 21-May-2016 deraadt

hand-massage sendsig() and sys_sigreturn() to be much more similar.
ok guenther kettenis


# 1.13 10-May-2016 deraadt

SROP mitigation. sendsig() stores a (per-process ^ &sigcontext) cookie
inside the sigcontext. sigreturn(2) checks syscall entry was from the
exact PC addr in the (per-process ASLR) sigtramp, verifies the cookie,
and clears it to prevent sigcontext reuse.
not yet tested on landisk, sparc, *88k, socppc.
ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.12 31-Jan-2016 jsg

Switch from PSR_X_bit and X32_bit PSR macro names to just PSR_X.
This matches FreeBSD and makes things a bit more consistent.
Discussed with Patrick.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.11 26-Mar-2014 guenther

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer. Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@


# 1.10 22-Mar-2014 guenther

Move p_sigacts from struct proc to struct process.

testing help mpi@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE
# 1.9 10-May-2013 patrick

Remove an instruction cache sync which is not needed.

ok miod@


Revision tags: OPENBSD_5_3_BASE
# 1.8 02-Dec-2012 guenther

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.7 20-Sep-2011 miod

Late spring cleaning of the arm code for old dusty bits we do not want to
keep:
- remove bootconfig parameter passing feature (unused).
- unifdef __PROG32 and remove all remains of arm26 code.
- remove ARMFPE support (unused).
- remove support for ARM2, ARM2AS, ARM3, ARM6, ARM7, ARM7TDMI and StrongARM
processor families, and the related silicon bug workarounds (especially
the SA-110 STM^ bug).
- remove cpu_functions no longer necessary after previous removals.
- remove ARM32_DISABLE_ALIGNMENT_FAULTS option (unused).
- make FIQ support conditional on option FIQ (unused, but may be eventually).

Discussed with drahn@ and jasper@ long ago, I was sitting on this commit for
no good reason.


Revision tags: OPENBSD_5_0_BASE
# 1.6 05-Jul-2011 guenther

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down. This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@


# 1.5 18-Apr-2011 guenther

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts). Until
that is untangled, the sigacts change is unsafe. sthen@ was the victim
for this one


# 1.4 16-Apr-2011 deraadt

another variable left after a commit


# 1.3 15-Apr-2011 guenther

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 16-Feb-2004 miod

branches: 1.2.2;
Correctly pass the siginfo_t structure to signal handlers.
ok drahn@


# 1.1 01-Feb-2004 drahn

Arm port, NetBSD codebase stripped down, 32bit only support.