From: Peter Zijlstra <peterz@infradead.org>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Masahiro Yamada" <masahiroy@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nicolas@fjasle.eu>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>, "Kees Cook" <kees@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.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>,
"Matthew Maurer" <mmaurer@google.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] cfi: add CONFIG_CFI_ICALL_NORMALIZE_INTEGERS
Date: Tue, 30 Jul 2024 12:28:56 +0200 [thread overview]
Message-ID: <20240730102856.GJ33588@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20240730-kcfi-v1-1-bbb948752a30@google.com>
On Tue, Jul 30, 2024 at 09:40:11AM +0000, Alice Ryhl wrote:
> Introduce a Kconfig option for enabling the experimental option to
> normalize integer types. This ensures that integer types of the same
> size and signedness are considered compatible by the Control Flow
> Integrity sanitizer.
>
> This option exists for compatibility with Rust, as C and Rust do not
> have the same set of integer types. There are cases where C has two
> different integer types of the same size and alignment, but Rust only
> has one integer type of that size and alignment. When Rust calls into
> C functions using such types in their signature, this results in CFI
> failures.
>
> This patch introduces a dedicated option for this because it is
> undesirable to have CONFIG_RUST affect CC_FLAGS in this way.
To be clear, any code compiled with this is incompatible with code
compiled without this, as the function signatures will differ, right?
Specifically, it will map things like 'unsigned long long' and 'unsigned
long' -- which are both u64 on LP64 targets to the same 'type', right?
I suppose it has been decided the security impact of this change is
minimal?
All in all, there is very little actual information provided here.
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> Makefile | 3 +++
> arch/Kconfig | 11 +++++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 2b5f9f098b6f..484c6900337e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -952,6 +952,9 @@ endif
>
> ifdef CONFIG_CFI_CLANG
> CC_FLAGS_CFI := -fsanitize=kcfi
> +ifdef CONFIG_CFI_ICALL_NORMALIZE_INTEGERS
> + CC_FLAGS_CFI += -fsanitize-cfi-icall-experimental-normalize-integers
> +endif
> KBUILD_CFLAGS += $(CC_FLAGS_CFI)
> export CC_FLAGS_CFI
> endif
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 975dd22a2dbd..f6ecb15cb8ba 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -826,6 +826,17 @@ config CFI_CLANG
>
> https://clang.llvm.org/docs/ControlFlowIntegrity.html
>
> +config CFI_ICALL_NORMALIZE_INTEGERS
> + bool "Normalize CFI tags for integers"
> + depends on CFI_CLANG
> + depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers)
> + help
> + This option normalizes the CFI tags for integer types so that all
> + integer types of the same size and signedness receive the same CFI
> + tag.
> +
> + This option is necessary for using CFI with Rust. If unsure, say N.
> +
> config CFI_PERMISSIVE
> bool "Use CFI in permissive mode"
> depends on CFI_CLANG
>
> --
> 2.46.0.rc1.232.g9752f9e123-goog
>
next prev parent reply other threads:[~2024-07-30 10:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 9:40 [PATCH 0/2] Rust KCFI support Alice Ryhl
2024-07-30 9:40 ` [PATCH 1/2] cfi: add CONFIG_CFI_ICALL_NORMALIZE_INTEGERS Alice Ryhl
2024-07-30 9:51 ` Alice Ryhl
2024-07-30 10:28 ` Peter Zijlstra [this message]
2024-07-30 15:19 ` Sami Tolvanen
2024-07-30 16:04 ` Peter Zijlstra
2024-07-30 16:10 ` Alice Ryhl
2024-07-30 11:38 ` Miguel Ojeda
2024-07-30 12:13 ` Peter Zijlstra
2024-07-30 16:10 ` Alice Ryhl
2024-07-30 18:01 ` Miguel Ojeda
2024-07-30 9:40 ` [PATCH 2/2] rust: cfi: add support for CFI_CLANG with Rust Alice Ryhl
2024-07-30 10:32 ` Peter Zijlstra
2024-07-30 15:24 ` Sami Tolvanen
2024-07-30 16:03 ` Peter Zijlstra
2024-07-30 16:26 ` Alice Ryhl
2024-07-30 11:50 ` Miguel Ojeda
2024-07-30 16:44 ` Alice Ryhl
2024-07-30 17:29 ` Miguel Ojeda
2024-07-30 10:38 ` [PATCH 0/2] Rust KCFI support Gary Guo
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=20240730102856.GJ33588@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=kees@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mmaurer@google.com \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--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