linux-stable/scripts
Alexander Potapenko f80be4571b kmsan: add KMSAN runtime core
For each memory location KernelMemorySanitizer maintains two types of
metadata:

1. The so-called shadow of that location - а byte:byte mapping describing
   whether or not individual bits of memory are initialized (shadow is 0)
   or not (shadow is 1).
2. The origins of that location - а 4-byte:4-byte mapping containing
   4-byte IDs of the stack traces where uninitialized values were
   created.

Each struct page now contains pointers to two struct pages holding KMSAN
metadata (shadow and origins) for the original struct page.  Utility
routines in mm/kmsan/core.c and mm/kmsan/shadow.c handle the metadata
creation, addressing, copying and checking.  mm/kmsan/report.c performs
error reporting in the cases an uninitialized value is used in a way that
leads to undefined behavior.

KMSAN compiler instrumentation is responsible for tracking the metadata
along with the kernel memory.  mm/kmsan/instrumentation.c provides the
implementation for instrumentation hooks that are called from files
compiled with -fsanitize=kernel-memory.

To aid parameter passing (also done at instrumentation level), each
task_struct now contains a struct kmsan_task_state used to track the
metadata of function parameters and return values for that task.

Finally, this patch provides CONFIG_KMSAN that enables KMSAN, and declares
CFLAGS_KMSAN, which are applied to files compiled with KMSAN.  The
KMSAN_SANITIZE:=n Makefile directive can be used to completely disable
KMSAN instrumentation for certain files.

Similarly, KMSAN_ENABLE_CHECKS:=n disables KMSAN checks and makes newly
created stack memory initialized.

Users can also use functions from include/linux/kmsan-checks.h to mark
certain memory regions as uninitialized or initialized (this is called
"poisoning" and "unpoisoning") or check that a particular region is
initialized.

Link: https://lkml.kernel.org/r/20220915150417.722975-12-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Marco Elver <elver@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-10-03 14:03:19 -07:00
..
atomic locking/atomic: Add generic try_cmpxchg64 support 2022-05-18 00:08:27 +02:00
basic randstruct: Move seed generation into scripts/basic/ 2022-05-08 01:33:07 -07:00
clang-tools scripts/clang-tools: Remove DeprecatedOrUnsafeBufferHandling check 2022-08-21 02:47:49 +09:00
coccinelle update Coccinelle URL 2022-08-07 21:30:36 +02:00
dtc h8300: remove stale bindings and symlink 2022-05-20 22:40:56 +02:00
dummy-tools kbuild: dummy-tools: pretend we understand __LONG_DOUBLE_128__ 2022-08-21 02:47:48 +09:00
gcc-plugins treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_385.RULE 2022-06-10 14:51:36 +02:00
gdb Updates to various subsystems which I help look after. lib, ocfs2, 2022-08-07 10:03:24 -07:00
genksyms genksyms: adjust the output format to modpost 2022-05-24 16:33:20 +09:00
kconfig kconfig: Qt5: tell the user which packages are required 2022-07-27 21:18:00 +09:00
ksymoops
mod modpost: fix module versioning when a symbol lacks valid CRC 2022-08-21 02:47:36 +09:00
package kbuild: rpm-pkg: fix build error when _arch is undefined 2022-07-27 21:18:00 +09:00
selinux selinux: declare data arrays const 2022-05-03 15:53:49 -04:00
tracing scripts/tracing: Fix typo 'the the' in comment 2022-08-02 15:17:00 -04:00
.gitignore
adjust_autoksyms.sh kbuild: split the second line of *.mod into *.usyms 2022-05-08 03:16:59 +09:00
as-version.sh
asn1_compiler.c
bin2c.c
bloat-o-meter scripts/bloat-o-meter: add -p argument 2022-07-17 17:31:40 -07:00
bootgraph.pl
bpf_doc.py bpf, docs: Use SPDX license identifier in bpf_doc.py 2022-07-22 00:28:14 +02:00
cc-can-link.sh
cc-version.sh
check-local-export scripts/check-local-export: avoid 'wait $!' for process substitution 2022-06-10 03:47:13 +09:00
check-sysctl-docs
check_extable.sh
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py
checkpatch.pl checkpatch: fix incorrect camelcase detection on numeric constant 2022-06-16 19:58:22 -07:00
checkstack.pl checkstack: add riscv support for scripts/checkstack.pl 2022-07-27 21:18:00 +09:00
checksyscalls.sh checksyscalls: ignore -Wunused-macros 2022-05-08 03:16:59 +09:00
checkversion.pl
cleanfile
cleanpatch
coccicheck
config
const_structs.checkpatch const_structs.checkpatch: add frequently used ops structs 2022-01-20 08:52:54 +02:00
decode_stacktrace.sh scripts/decode_stacktrace.sh: support old bash version 2022-04-29 14:37:57 -07:00
decodecode
depmod.sh
dev-needs.sh
diffconfig
documentation-file-ref-check
export_report.pl
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line scripts/faddr2line: Add CONFIG_DEBUG_INFO check 2022-08-02 22:08:17 +02:00
file-size.sh
find-unused-docs.sh
gcc-ld
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen-randstruct-seed.sh randstruct: Move seed generation into scripts/basic/ 2022-05-08 01:33:07 -07:00
gen_autoksyms.sh kbuild: Ignore __this_module in gen_autoksyms.sh 2022-06-26 06:15:05 +09:00
gen_ksymdeps.sh
generate_initcall_order.pl
get_abi.pl scripts/get_abi: Fix wrong script file name in the help message 2022-04-24 10:38:44 +02:00
get_dvb_firmware
get_feat.pl scripts: get_feat.pl: use /usr/bin/env to find perl 2022-06-30 12:22:17 -06:00
get_maintainer.pl get_maintainer: Honor mailmap for in file emails 2022-04-29 14:38:00 -07:00
gfp-translate
headerdep.pl
headers_install.sh scripts: headers_install.sh: Update config leak ignore entries 2022-07-27 21:18:00 +09:00
insert-sys-cert.c
install.sh kbuild: factor out the common installation code into scripts/install.sh 2022-05-11 21:45:53 +09:00
jobserver-exec
kallsyms.c scripts/kallsyms: update usage message of the kallsyms program 2022-05-27 15:51:48 +09:00
Kbuild.include kbuild: add cmd_and_savecmd macro 2022-06-01 23:07:29 +09:00
Kconfig.include kbuild: set EXIT trap before creating temporary directory 2022-08-03 22:56:38 +09:00
kernel-doc scripts: kernel-doc: Always increment warnings counter 2022-06-13 11:07:45 -06:00
ld-version.sh
leaking_addresses.pl
Lindent
link-vmlinux.sh kbuild: factor out the common objtool arguments 2022-06-05 06:20:57 +09:00
Makefile kbuild: Allow kernel installation packaging to override pkg-config 2022-04-05 17:03:31 +09:00
Makefile.asm-generic
Makefile.build kbuild: remove sed command from cmd_ar_builtin 2022-07-27 21:17:59 +09:00
Makefile.clang um: Allow builds with Clang 2022-03-21 08:13:03 -07:00
Makefile.clean kbuild: drop $(objtree)/ prefix support for clean-files 2022-05-08 03:17:00 +09:00
Makefile.compiler kbuild: set EXIT trap before creating temporary directory 2022-08-03 22:56:38 +09:00
Makefile.debug
Makefile.dtbinst
Makefile.extrawarn scripts/Makefile.extrawarn: Do not disable clang's -Wformat-zero-length 2022-08-21 02:47:48 +09:00
Makefile.gcc-plugins gcc-plugins: Undefine LATENT_ENTROPY_PLUGIN when plugin disabled for a file 2022-08-16 12:25:53 -07:00
Makefile.headersinst
Makefile.host
Makefile.kasan
Makefile.kcov
Makefile.kcsan
Makefile.kmsan kmsan: add KMSAN runtime core 2022-10-03 14:03:19 -07:00
Makefile.lib kmsan: add KMSAN runtime core 2022-10-03 14:03:19 -07:00
Makefile.modfinal kbuild: do not create *.prelink.o for Clang LTO or IBT 2022-05-29 18:39:35 +09:00
Makefile.modinst kbuild: error out if $(INSTALL_MOD_PATH) contains % or : 2022-07-27 21:18:00 +09:00
Makefile.modpost kbuild: do not create *.prelink.o for Clang LTO or IBT 2022-05-29 18:39:35 +09:00
Makefile.package kbuild: rpm-pkg: pass 'linux' to --target option of rpmbuild 2022-07-27 21:18:00 +09:00
Makefile.randstruct randstruct: Enable Clang support 2022-05-08 01:33:07 -07:00
Makefile.ubsan ubsan: remove CONFIG_UBSAN_OBJECT_SIZE 2022-01-20 08:52:55 +02:00
Makefile.userprogs
Makefile.vmlinux kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS 2022-05-24 16:33:20 +09:00
Makefile.vmlinux_o x86/retbleed: Add fine grained Kconfig knobs 2022-06-29 17:43:41 +02:00
makelst
markup_oops.pl
min-tool-version.sh scripts/min-tool-version.sh: raise minimum clang version to 14.0.0 for s390 2022-05-17 15:16:29 +02:00
mkcompile_h sched/preempt: Tell about PREEMPT_DYNAMIC on kernel headers 2022-03-11 15:36:35 +01:00
mksysmap
mkuboot.sh
module.lds.S modules: Ensure natural alignment for .altinstructions and __bug_table sections 2022-07-11 10:49:14 -07:00
modules-check.sh
nsdeps scripts/nsdeps: adjust to the format change of *.mod files 2022-06-08 20:14:13 +09:00
objdiff kbuild: clean .tmp_* pattern by make clean 2022-06-05 06:20:57 +09:00
objdump-func scripts: Create objdump-func helper script 2022-05-12 10:08:43 -07:00
pahole-flags.sh scripts/pahole-flags.sh: Parse DWARF and generate BTF with multithreading. 2022-02-22 14:32:44 -08:00
pahole-version.sh kbuild: Add CONFIG_PAHOLE_VERSION 2022-02-02 11:19:33 +01:00
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel scripts/prune-kernel: Use kernel-install if available 2022-05-11 21:46:38 +09:00
recordmcount.c
recordmcount.h
recordmcount.pl nds32: Remove the architecture 2022-03-07 13:54:59 +01:00
remove-stale-files RISC-V Patches for the 5.20 Merge Window, Part 2 2022-08-12 18:39:43 -07:00
setlocalversion
show_delta
sign-file.c sign-file: Fix confusing error messages 2022-08-03 23:56:20 +03:00
sorttable.c LoongArch: Add ELF-related definitions 2022-06-03 20:09:27 +08:00
sorttable.h script/sorttable: Fix some initialization problems 2022-01-18 10:17:18 -05:00
spdxcheck-test.sh docs: move Linux logo into a new images folder 2022-06-01 09:32:45 -06:00
spdxcheck.py scripts/spdxcheck: Put excluded files and directories into a separate file 2022-05-18 15:34:33 +02:00
spdxexclude scripts/spdxcheck: Exclude top-level README 2022-05-18 15:35:42 +02:00
spelling.txt scripts/spelling.txt: add more spellings to spelling.txt 2022-03-22 15:57:00 -07:00
sphinx-pre-install scripts: sphinx-pre-install: place a warning for Sphinx >= 3.0 2022-07-07 12:47:34 -06:00
split-man.pl
stackdelta
stackusage
subarch.include LoongArch: Add build infrastructure 2022-06-03 20:09:27 +08:00
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh scripts/tags.sh: Include tools directory in tags generation 2022-07-01 10:32:30 +02:00
test_fortify.sh fortify: Update compile-time tests for Clang 14 2022-02-13 16:50:06 -08:00
tools-support-relr.sh
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh