From: Dmitry Vyukov <dvyukov@google.com>
To: Andrey Konovalov <andreyknvl@gmail.com>
Cc: "Matthew Maurer" <mmaurer@google.com>,
"Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Alexander Potapenko" <glider@google.com>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
"Nicolas Schier" <nicolas@fjasle.eu>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
llvm@lists.linux.dev,
"Brendan Higgins" <brendanhiggins@google.com>
Subject: Re: [PATCH 2/2] kbuild: rust: Enable KASAN support
Date: Fri, 26 Jul 2024 12:23:01 +0200 [thread overview]
Message-ID: <CACT4Y+Y+XmdNervhF5WAEyVwprJ32m7Pd8FF2fKy3K9FiTpJtQ@mail.gmail.com> (raw)
In-Reply-To: <CA+fCnZdwRcdOig0u-D0vnFz937hRufTQOpCqGiMeo5B+-1iRVA@mail.gmail.com>
On Fri, 26 Jul 2024 at 01:57, Andrey Konovalov <andreyknvl@gmail.com> wrote:
>
> On Fri, Jul 26, 2024 at 1:21 AM Matthew Maurer <mmaurer@google.com> wrote:
> >
> > Rust supports KASAN via LLVM, but prior to this patch, the flags aren't
> > set properly.
This is great, thanks, Matthew!
Does Rust support KUnit tests?
It would be good to add at least a simple positive test similar to the
existing ones so that the support does not get rotten soon.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/kasan/kasan_test.c
> > Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> > Signed-off-by: Matthew Maurer <mmaurer@google.com>
>
> Hi Matthew,
>
> > CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
> > +RUSTFLAGS_KASAN_MINIMAL := -Zsanitizer=kernel-address -Zsanitizer-recover=kernel-address
>
> If I recall correctly, the reason we need CFLAGS_KASAN_MINIMAL is
> because older compilers don't support some of the additional options.
> With Rust, this shouldn't be needed, as it requires a modern compiler
> that does support all needed options. E.g., for CONFIG_KASAN_SW_TAGS,
> we also don't have the MINIMAL thing for the same reason. (Possibly,
> we also already don't need this for GENERIC KASAN, as the GCC version
> requirement was raised a few times since KASAN was introduced.)
>
> > # Now add all the compiler specific options that are valid standalone
> > CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \
> > $(call cc-param,asan-globals=1) \
> > $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \
> > $(call cc-param,asan-instrument-allocas=1)
> > + ifdef CONFIG_RUST
> > + RUSTFLAGS_KASAN := $(RUSTFLAGS_KASAN_SHADOW) \
> > + $(call rustc-param,asan-globals=1) \
> > + $(call rustc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \
> > + $(call rustc-param,asan-instrument-allocas=1)
>
> I'm wondering if there's a way to avoid duplicating all options for
> Rust. Perhaps, some kind of macro?
>
> Thanks!
next prev parent reply other threads:[~2024-07-26 10:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 23:20 [PATCH 0/2] Rust KASAN Support Matthew Maurer
2024-07-25 23:20 ` [PATCH 1/2] kbuild: rust: Define probing macros for rustc Matthew Maurer
2024-07-25 23:20 ` [PATCH 2/2] kbuild: rust: Enable KASAN support Matthew Maurer
2024-07-25 23:57 ` Andrey Konovalov
2024-07-26 10:23 ` Dmitry Vyukov [this message]
2024-07-26 12:36 ` Miguel Ojeda
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=CACT4Y+Y+XmdNervhF5WAEyVwprJ32m7Pd8FF2fKy3K9FiTpJtQ@mail.gmail.com \
--to=dvyukov@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=brendanhiggins@google.com \
--cc=gary@garyguo.net \
--cc=glider@google.com \
--cc=justinstitt@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=mmaurer@google.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=vincenzo.frascino@arm.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).