Revision f8836e87af2305f34053e6936f81d3f91be7aac4 authored by Alexander Potapenko on 21 November 2019, 15:52:59 UTC, committed by Alexander Potapenko on 24 September 2021, 14:36:25 UTC
Make KMSAN usable by adding the necessary Kconfig bits. Signed-off-by: Alexander Potapenko <glider@google.com> --- This patch was previously called "kmsan: Changing existing files to enable KMSAN builds". Logically unrelated parts of it were split away. v4: - split away changes to init/main.c as requested by Andrey Konovalov v6: - moved Makefile changes to the core patch Link: https://linux-review.googlesource.com/id/I1d295ce8159ce15faa496d20089d953a919c125e
1 parent f57cc79
README.md
# KMSAN (KernelMemorySanitizer)
`KMSAN` is a detector of uninitialized memory use for the Linux kernel. It is
currently in development.
Contact: @ramosian-glider
## Code
* The kernel branch with KMSAN patches is available at https://github.com/google/kmsan
* These will be upstreamed someday, stay tuned!
## How to build
```
export WORLD=`pwd`
```
In order to build a kernel with KMSAN you'll need a fresh Clang. Please refer to https://clang.llvm.org/get_started.html and https://llvm.org/docs/CMake.html for the instructions on how to build Clang. Otherwise, consider using prebuilt compiler binaries from the Chromium project:
```
cd $WORLD
# Instruction taken from http://llvm.org/docs/LibFuzzer.html
mkdir TMP_CLANG
cd TMP_CLANG
git clone https://chromium.googlesource.com/chromium/src/tools/clang
cd ..
TMP_CLANG/clang/scripts/update.py
cd $WORLD
export KMSAN_CLANG_PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin/
```
### Configure and build the kernel
```
cd $WORLD
git clone https://github.com/google/kmsan.git kmsan
cd kmsan
# Now configure the kernel. You basically need to enable CONFIG_KMSAN and CONFIG_KCOV,
# plus maybe some 9P options to interact with QEMU.
cp .config.example .config
make CC=$KMSAN_CLANG_PATH -j64 -k 2>&1 | tee build.log
```
### Run the kernel
You can refer to https://github.com/ramosian-glider/clang-kernel-build for the instructions
on running the freshly built kernel in a QEMU VM.
Also consider running a KMSAN-instrumented kernel under [syzkaller](https://github.com/google/syzkaller).
## Trophies
See https://github.com/google/kmsan/wiki/KMSAN-Trophies for the list of trophies.
## Known issues
1. `CONFIG_DRM_AMD_DC_DCN1_0` doesn't work with Clang because of https://bugs.llvm.org/show_bug.cgi?id=38738.
To work around the problem, disable `CONFIG_DRM_AMD_DC`
2. `CONFIG_UNWINDER_ORC` doesn't work yet, use `CONFIG_UNWINDER_FRAME_POINTER`.
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...