From: Matthew Maurer <mmaurer@google.com>
To: dvyukov@google.com, ojeda@kernel.org, andreyknvl@gmail.com,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@gmail.com>,
Nathan Chancellor <nathan@kernel.org>
Cc: aliceryhl@google.com, samitolvanen@google.com,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
glider@google.com, ryabinin.a.a@gmail.com,
"Matthew Maurer" <mmaurer@google.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
rust-for-linux@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH v3 0/4] Rust KASAN Support
Date: Mon, 19 Aug 2024 21:35:18 +0000 [thread overview]
Message-ID: <20240819213534.4080408-1-mmaurer@google.com> (raw)
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 v2 [3]:
1. Rebased on top of the maintainer's cleanup of the Makefile.
2. Cleaned up the UaF test based on feedback.
3. Calls out that KASAN_SW_TAGS is not yet supported in the config.
The notable piece of feedback I have not followed is in the renaming of
kasan_test.c to kasan_test_c.c - this was done in order to allow the
module to be named kasan_test but consist of two .o files. The other
options I see are renaming the test suite or creating a separate Rust
test suite, but both of those seemed more invasive than the rename. Let
me know if you have another approach you'd prefer there.
[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/20240812232910.2026387-1-mmaurer@google.com/
Matthew Maurer (4):
kbuild: rust: Define probing macros for rustc
kbuild: rust: Enable KASAN support
rust: kasan: Rust does not support KHWASAN
kasan: rust: Add KASAN smoke test via UAF
init/Kconfig | 1 +
mm/kasan/Makefile | 9 +++-
mm/kasan/kasan.h | 1 +
mm/kasan/{kasan_test.c => kasan_test_c.c} | 11 +++++
mm/kasan/kasan_test_rust.rs | 19 ++++++++
scripts/Kconfig.include | 8 ++++
scripts/Makefile.compiler | 15 +++++++
scripts/Makefile.kasan | 54 ++++++++++++++++-------
scripts/Makefile.lib | 3 ++
scripts/generate_rust_target.rs | 1 +
10 files changed, 105 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
next reply other threads:[~2024-08-19 21:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 21:35 Matthew Maurer [this message]
2024-08-19 21:35 ` [PATCH v3 1/4] kbuild: rust: Define probing macros for rustc Matthew Maurer
2024-08-20 14:20 ` Miguel Ojeda
2024-08-20 17:22 ` Matthew Maurer
2024-08-20 20:49 ` Miguel Ojeda
2024-08-19 21:35 ` [PATCH v3 2/4] kbuild: rust: Enable KASAN support Matthew Maurer
2024-08-20 17:30 ` Andrey Konovalov
2024-08-19 21:35 ` [PATCH v3 3/4] rust: kasan: Rust does not support KHWASAN Matthew Maurer
2024-08-20 17:30 ` Andrey Konovalov
2024-08-19 21:35 ` [PATCH v3 4/4] kasan: rust: Add KASAN smoke test via UAF Matthew Maurer
2024-08-20 17:37 ` Andrey Konovalov
2024-08-20 14:19 ` [PATCH v3 0/4] Rust KASAN Support Miguel Ojeda
2024-08-20 17:28 ` Andrey Konovalov
2024-08-20 17:55 ` Alice Ryhl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240819213534.4080408-1-mmaurer@google.com \
--to=mmaurer@google.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andreyknvl@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dvyukov@google.com \
--cc=gary@garyguo.net \
--cc=glider@google.com \
--cc=justinstitt@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=samitolvanen@google.com \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).