freebsd-dev/sys/arm64/include
Mark Johnston 03bf40c5d8 arm64: Disable per-thread stack-smashing protection in data_abort()
With PERTHREAD_SSP configured, the compiler's stack-smashing protection
uses a per-thread canary value instead of a global value.  The value is
stored in td->td_md.md_canary; the sp_el0 register always contains a
pointer to that value, and certain functions selected by the compiler
will store the canary value on the stack as a part of the function
prologue (and will verify the copy as part of the epilogue).  In
particular, the thread structure may be accessed.

This happens to occur in data_abort(), which leads to the same problem
addressed by commit 2c10be9e06 ("arm64: Handle translation faults for
thread structures").  This commit fixes that directly, by disabling SSP
in data_abort() and a couple of related functions by using a function
attribute.  It also moves the update of sp_el0 out of C code in case
the compiler decides to start checking the canary in pmap_switch()
someday.

A different solution might be to move the canary value to the PCB, which
currently lives on the kernel stack and isn't subject to the same
problem as thread structures (if only because guard pages inhibit
superpage promotion).  However, there isn't any particular reason the
PCB has to live on the stack today; on amd64 it is embedded in struct
thread, reintroducing the same problem.  Keeping the reference canary
value at the top of the stack is also rather dubious since it could be
clobbered by a sufficiently large stack overflow.

A third solution could be to go back to the approach of commit
5aa5420ff2, and modify UMA to use the direct map for thread structures
even if KASAN is enabled.  But, transient promotions and demotions in
the direct map are possible too.

Reviewed by:	alc, kib, andrew
MFC after:	1 month
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37255
2022-11-07 16:05:58 -05:00
..
_align.h
_bus.h
_inttypes.h
_limits.h
_stdint.h
_types.h Reduce code duplication in machine/_types.h 2021-06-14 16:30:16 +01:00
acpica_machdep.h
armreg.h Decode the arm64 ID_AA64ISAR1_EL1 register 2022-09-06 16:49:36 +01:00
asm.h Handle functions that use a nop in the arm64 fbt 2021-03-03 14:18:03 +00:00
atomic.h Fix the sanitizer header checks on arm64 2022-02-23 14:50:56 +00:00
bus_dma_impl.h bus_dma: Deduplicate locking helper functions. 2022-01-05 13:50:40 -08:00
bus_dma.h
bus.h arm64: bus: provide bus_space_set_{multi,region}_stream definitions 2022-09-26 14:24:37 -05:00
clock.h
cmn600_reg.h Add support of ARM CMN-600 controller, PMU access functions only. Add support of PMU counters of ARM CMN-600 controller. 2022-06-26 22:03:04 +03:00
counter.h Allocate arm64 per-CPU data in the correct domain 2021-10-11 10:36:50 +01:00
cpu.h Add more Arm CPUs to the arm64 cpu ident 2022-10-11 14:01:16 +01:00
cpufunc.h Add an IDC only arm64 icache sync function 2022-08-25 12:17:28 +01:00
csan.h arm64: Improve DDB backtrace support 2021-02-01 14:15:57 +00:00
db_machdep.h arm64: Fix a logic bug in is_load_instr(). 2021-09-15 09:03:18 -07:00
debug_monitor.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
disassem.h
dump.h minidump: De-duplicate the progress bar 2021-09-29 16:42:21 -03:00
efi.h smbios: support getting address from EFI 2021-04-07 14:46:29 -05:00
elf.h arm, arm64: tweak hard-coded load addresses for PIE binaries 2022-10-25 19:00:44 +03:00
endian.h Consolidate machine/endian.h definitions 2021-03-26 19:00:22 -03:00
exec.h
float.h
floatingpoint.h
fpu.h
frame.h
gdb_machdep.h gdb: report specific stop reason for watchpoints 2021-03-30 11:36:41 -03:00
hypervisor.h Mark 64-bit arm64 hypervisor registers with UL 2022-10-11 14:01:16 +01:00
ieeefp.h
ifunc.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
in_cksum.h machine/in_cksum.h: don't include sys/cdefs.h 2022-04-18 21:02:19 +01:00
intr.h
iodev.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
iommu.h
kdb.h arm64: implement kdb watchpoint functions 2021-03-29 12:05:43 -03:00
machdep.h Remove unneeded variables in the arm64 pmap bootstrap 2022-09-27 14:47:30 +01:00
md_var.h Simplify swi for bus_dma. 2021-12-28 13:51:25 -08:00
memdev.h
metadata.h
minidump.h Make page size dynamic in libkvm for arm64 2022-03-15 09:52:15 +00:00
ofw_machdep.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
param.h arm64: Disable per-thread stack-smashing protection in data_abort() 2022-11-07 16:05:58 -05:00
pcb.h Move the non-exported PCB_FP_* flags to the upper bits 2022-09-08 14:23:20 +01:00
pci_cfgreg.h Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2021-08-08 10:42:24 -04:00
pcpu_aux.h Allocate arm64 per-CPU data in the correct domain 2021-10-11 10:36:50 +01:00
pcpu.h Store mpidr as a 64-bit value on arm64 2022-08-31 11:48:31 +01:00
pmap.h sys: Consolidate common implementation details of PV entries. 2022-10-07 10:14:03 -07:00
pmc_mdep.h Allocate event for DMC-620 and CMN-600 controllers PMU. Add events supported by DMC-620 and CMN-600 controllers PMU. 2022-06-26 21:52:26 +03:00
proc.h Add arm64 pointer authentication support 2022-01-12 15:27:17 +00:00
procctl.h
profile.h Remove checks for __GNUCLIKE_ASM assuming it is always true. 2022-04-12 10:05:45 -07:00
psl.h
pte.h Disable promotion on pcpu memory on arm64 2022-08-16 15:41:24 +01:00
ptrace.h arm64: Implement cpu_ptrace(). 2022-10-27 23:25:56 +02:00
reg.h Add NT_ARM_ADDR_MASK 2022-02-22 17:10:35 +00:00
reloc.h
resource.h
runq.h
setjmp.h
sf_buf.h
sigframe.h
signal.h
smp.h
stack.h arm64: Improve DDB backtrace support 2021-02-01 14:15:57 +00:00
stdarg.h
sysarch.h
tls.h Add <machine/tls.h> header to hold MD constants and helpers for TLS. 2021-12-09 13:17:13 -08:00
trap.h
ucontext.h
undefined.h
vdso.h
vfp.h Split out vfp_new_thread 2022-06-29 15:15:43 +01:00
vm.h Add a way to map arm64 non-posted device memory 2021-05-01 06:01:20 +00:00
vmparam.h Fix the arm64 DMAP start address in a comment 2022-03-10 11:00:44 +00:00