Skip to content

Rust KASAN Support

Matthew Maurer linux-kbuild linux-mm lkml llvm rust-for-linux 4 versions – Applied

Status from this message: Applied to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 8 repliesApplied
  2. v34 patches 9 repliesSuperseded
  3. v23 patches 5 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches3 repliesSuperseded

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/4kbuild: rust: Define probing macros for rustcscripts/Kconfig.include scripts/Makefile.compiler+23 -00 replies
2/4rust: kasan: Rust does not support KHWASANinit/Kconfig+1 -00 replies
3/4kbuild: rust: Enable KASAN supportscripts/Makefile.kasan scripts/Makefile.lib scripts/generate_rust_target.rs+45 -161 reply
4/4kasan: rust: Add KASAN smoke test via UAFmm/kasan/Makefile mm/kasan/kasan.h mm/kasan/kasan_test_c.c +1 more+43 -11 reply

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAndrey Konovalov
SeriesR-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/4] Rust KASAN Support

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/[email protected]/
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]/

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
Signature · 1 line
2.46.0.184.g6999bdac58-goog