opnsense-src/sys/amd64
Mark Johnston 756bc3adc5 kasan: Create a shadow for the bootstack prior to hammer_time()
When the kernel is compiled with -asan-stack=true, the address sanitizer
will emit inline accesses to the shadow map.  In other words, some
shadow map accesses are not intercepted by the KASAN runtime, so they
cannot be disabled even if the runtime is not yet initialized by
kasan_init() at the end of hammer_time().

This went unnoticed because the loader will initialize all PML4 entries
of the bootstrap page table to point to the same PDP page, so early
shadow map accesses do not raise a page fault, though they are silently
corrupting memory.  In fact, when the loader does not copy the staging
area, we do get a page fault since in that case only the first and last
PML4Es are populated by the loader.  But due to another bug, the loader
always treated KASAN kernels as non-relocatable and thus always copied
the staging area.

It is not really practical to annotate hammer_time() and all callees
with __nosanitizeaddress, so instead add some early initialization which
creates a shadow for the boot stack used by hammer_time().  This is only
needed by KASAN, not by KMSAN, but the shared pmap code handles both.

Reported by:	mhorne
Reviewed by:	kib
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35449
2022-06-15 11:39:10 -04:00
..
acpica amd64: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:46:59 -07:00
amd64 kasan: Create a shadow for the bootstack prior to hammer_time() 2022-06-15 11:39:10 -04:00
conf ktls: Remove the KERN_TLS option from the i386 and amd64 LINT-NOIP kernel configurations. 2022-06-11 21:31:28 +02:00
ia32 x86: Add a NT_X86_SEGBASES register set. 2022-03-24 11:36:19 -07:00
include kasan: Create a shadow for the bootstack prior to hammer_time() 2022-06-15 11:39:10 -04:00
linux linux(4): Properly build argument list for the signal handler 2022-05-30 19:53:12 +03:00
linux32 linux(4): Properly restore the thread signal mask after signal delivery on i386 2022-05-30 20:03:49 +03:00
pci pci_cfgreg.c: Use io port config access for early boot time. 2019-04-09 18:07:17 +00:00
sgx sgx: Remove unused variable. 2022-04-07 17:01:28 -07:00
vmm vmm: move bumping VMEXIT_USERSPACE stat to the right place 2022-06-09 08:57:25 -04:00
Makefile Bring the tags and links entries for amd64 up to date. 2021-09-27 20:04:51 -07:00