freebsd-dev/share
Mark Johnston 38da497a4d Add the KASAN runtime
KASAN enables the use of LLVM's AddressSanitizer in the kernel.  This
feature makes use of compiler instrumentation to validate memory
accesses in the kernel and detect several types of bugs, including
use-after-frees and out-of-bounds accesses.  It is particularly
effective when combined with test suites or syzkaller.  KASAN has high
CPU and memory usage overhead and so is not suited for production
environments.

The runtime and pmap maintain a shadow of the kernel map to store
information about the validity of memory mapped at a given kernel
address.

The runtime implements a number of functions defined by the compiler
ABI.  These are prefixed by __asan.  The compiler emits calls to
__asan_load*() and __asan_store*() around memory accesses, and the
runtime consults the shadow map to determine whether a given access is
valid.

kasan_mark() is called by various kernel allocators to update state in
the shadow map.  Updates to those allocators will come in subsequent
commits.

The runtime also defines various interceptors.  Some low-level routines
are implemented in assembly and are thus not amenable to compiler
instrumentation.  To handle this, the runtime implements these routines
on behalf of the rest of the kernel.  The sanitizer implementation
validates memory accesses manually before handing off to the real
implementation.

The sanitizer in a KASAN-configured kernel can be disabled by setting
the loader tunable debug.kasan.disable=1.

Obtained from:	NetBSD
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29416
2021-04-13 17:42:20 -04:00
..
colldef Add collation version support to querylocale(3). 2020-11-08 02:50:34 +00:00
ctypedef Fix CTYPE for ja_JP.eucJP and ja_JP.SJIS. 2020-06-29 03:23:13 +00:00
dict
doc pkgbase: Install atf and kyua in the tests package 2021-01-04 16:20:47 +01:00
dtrace Add dtrace SDT probe ipfw:::rule-matched. 2020-10-21 15:01:33 +00:00
examples Remove references to the now-removed bktr(4) driver. 2021-03-07 00:09:22 +00:00
i18n
keys
man Add the KASAN runtime 2021-04-13 17:42:20 -04:00
misc pci_vendors: update to 2021.02.20 2021-02-21 06:09:03 +01:00
mk pfctl: Move ioctl abstraction functions into libpfctl 2021-04-10 11:16:02 +02:00
monetdef
msgdef
numericdef
security
sendmail
skel
snmp Add entries for the OID used for NFS-over-TLS "user@domain". 2020-09-03 20:42:30 +00:00
syscons syscons: scrnmaps: appease -Wmissing-variable-declarations 2021-01-01 11:53:47 -06:00
tabset
termcap termcap: add an entry for the foot terminal 2021-02-21 06:06:47 +01:00
tests
timedef
vt vt/fonts: fix typo 2020-12-02 09:42:02 +00:00
zoneinfo pkgbase: Put zoneinfo file in their own package 2021-01-04 16:18:36 +01:00
Makefile Revert "terminfo: add terminfo database" 2021-03-18 10:57:23 +01:00
Makefile.inc