rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Rust KASAN Support
@ 2024-08-20 19:48 Matthew Maurer
  2024-08-20 19:48 ` [PATCH v4 1/4] kbuild: rust: Define probing macros for rustc Matthew Maurer
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Matthew Maurer @ 2024-08-20 19:48 UTC (permalink / raw)
  To: andreyknvl, ojeda, Alex Gaynor, Wedson Almeida Filho,
	Nathan Chancellor
  Cc: dvyukov, aliceryhl, samitolvanen, kasan-dev, linux-mm, glider,
	ryabinin.a.a, Matthew Maurer, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Nick Desaulniers, Bill Wendling, Justin Stitt, rust-for-linux,
	llvm

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, and is rebased on top of the KASAN Makefile rewrite [2].

Differences from v3 [3]:
* Probing macro comments made more accurate
* Probing macros now set --out-dir to avoid potential read-only fs
  issues
* Reordered KHWASAN explicit disablement patch to come before KASAN
  enablement
* Comment/ordering cleanup in KASAN makefile
* Ensured KASAN tests work with and without CONFIG_RUST enabled

[1] https://lore.kernel.org/lkml/20240730-target-json-arrays-v1-1-2b376fd0ecf4@google.com/
[2] https://lore.kernel.org/all/20240813224027.84503-1-andrey.konovalov@linux.dev
[3] https://lore.kernel.org/all/20240819213534.4080408-1-mmaurer@google.com/

Matthew Maurer (4):
  kbuild: rust: Define probing macros for rustc
  rust: kasan: Rust does not support KHWASAN
  kbuild: rust: Enable KASAN support
  kasan: rust: Add KASAN smoke test via UAF

 init/Kconfig                              |  1 +
 mm/kasan/Makefile                         |  7 ++-
 mm/kasan/kasan.h                          |  6 +++
 mm/kasan/{kasan_test.c => kasan_test_c.c} | 12 +++++
 mm/kasan/kasan_test_rust.rs               | 19 ++++++++
 scripts/Kconfig.include                   |  8 ++++
 scripts/Makefile.compiler                 | 15 ++++++
 scripts/Makefile.kasan                    | 57 ++++++++++++++++-------
 scripts/Makefile.lib                      |  3 ++
 scripts/generate_rust_target.rs           |  1 +
 10 files changed, 112 insertions(+), 17 deletions(-)
 rename mm/kasan/{kasan_test.c => kasan_test_c.c} (99%)
 create mode 100644 mm/kasan/kasan_test_rust.rs

-- 
2.46.0.184.g6999bdac58-goog


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-09-25 10:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 19:48 [PATCH v4 0/4] Rust KASAN Support Matthew Maurer
2024-08-20 19:48 ` [PATCH v4 1/4] kbuild: rust: Define probing macros for rustc Matthew Maurer
2024-08-20 19:48 ` [PATCH v4 2/4] rust: kasan: Rust does not support KHWASAN Matthew Maurer
2024-08-20 19:48 ` [PATCH v4 3/4] kbuild: rust: Enable KASAN support Matthew Maurer
2024-08-20 19:57   ` Andrey Konovalov
2024-08-20 19:48 ` [PATCH v4 4/4] kasan: rust: Add KASAN smoke test via UAF Matthew Maurer
2024-08-20 19:57   ` Andrey Konovalov
2024-08-20 19:57 ` [PATCH v4 0/4] Rust KASAN Support Andrey Konovalov
2024-09-16 16:15 ` Miguel Ojeda
2024-09-16 16:46   ` Miguel Ojeda
2024-09-25  8:26     ` Alice Ryhl
2024-09-25 10:00       ` Alice Ryhl
2024-09-25 10:20         ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).