Thread (6 messages) 6 messages, 3 authors, 2024-08-14

[PATCH v2 0/3] Rust KASAN Support

From: Matthew Maurer <hidden>
Date: 2024-08-12 23:29:16
Also in: rust-for-linux

Right now, if we turn on KASAN, Rust code will cause violations because
it's not enabled properly.

This series:
1. Adds flag probe macros for Rust - now that we're setting a minimum rustc
   version instead of an exact one, these could be useful in general. We need
   them in this patch because we don't set a restriction on which LLVM rustc
   is using, which is what KASAN actually cares about.
2. Makes `rustc` enable the relevant KASAN sanitizer flags when C does.
3. Adds a smoke test to the `kasan_test` KUnit suite to check basic
   integration.

This patch series requires the target.json array support patch [1] as
the x86_64 target.json file currently produced does not mark itself as KASAN
capable.

Differences from v1 [2] :
1. Reworked KASAN Makefile to avoid repetition, as requested [3]
2. Added a KUnit smoke test to avoid bitrot, as requested [4]
3. Added `kernel-address` to the target.json (my local base-tree had this
   from another patch series)

[1] https://lore.kernel.org/lkml/20240730-target-json-arrays-v1-1-2b376fd0ecf4@google.com/ (local)
[2] https://lore.kernel.org/llvm/20240725232126.1996981-1-mmaurer@google.com/ (local)
[3] https://lore.kernel.org/llvm/CA+fCnZdwRcdOig0u-D0vnFz937hRufTQOpCqGiMeo5B+-1iRVA@mail.gmail.com/ (local)
[4] https://lore.kernel.org/llvm/CACT4Y+Y+XmdNervhF5WAEyVwprJ32m7Pd8FF2fKy3K9FiTpJtQ@mail.gmail.com/ (local)

Matthew Maurer (3):
  kbuild: rust: Define probing macros for rustc
  kbuild: rust: Enable KASAN support
  kasan: rust: Add KASAN smoke test via UAF

 mm/kasan/Makefile                         |  9 +++-
 mm/kasan/{kasan_test.c => kasan_test_c.c} | 13 ++++++
 mm/kasan/kasan_test_rust.rs               | 17 ++++++++
 scripts/Kconfig.include                   |  8 ++++
 scripts/Makefile.compiler                 | 15 +++++++
 scripts/Makefile.kasan                    | 51 ++++++++++++++++-------
 scripts/Makefile.lib                      |  3 ++
 scripts/generate_rust_target.rs           |  1 +
 8 files changed, 101 insertions(+), 16 deletions(-)
 rename mm/kasan/{kasan_test.c => kasan_test_c.c} (99%)
 create mode 100644 mm/kasan/kasan_test_rust.rs

-- 
2.46.0.76.ge559c4bf1a-goog
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help