lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240724204055.3250c1cc.gary@garyguo.net>
Date: Wed, 24 Jul 2024 20:40:55 +0100
From: Gary Guo <gary@...yguo.net>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>, Peter Zijlstra
 <peterz@...radead.org>, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar
 <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, Dave Hansen
 <dave.hansen@...ux.intel.com>, Masahiro Yamada <masahiroy@...nel.org>,
 x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>, Nathan Chancellor
 <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>, Wedson Almeida
 Filho <wedsonaf@...il.com>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng
 <boqun.feng@...il.com>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>, Andreas
 Hindborg <a.hindborg@...sung.com>, Alice Ryhl <aliceryhl@...gle.com>,
 rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
 patches@...ts.linux.dev
Subject: Re: [PATCH v2 3/6] x86/rust: support MITIGATION_RETHUNK

On Wed, 24 Jul 2024 18:14:56 +0200
Miguel Ojeda <ojeda@...nel.org> wrote:

> The Rust compiler added support for `-Zfunction-return=thunk-extern` [1]
> in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`.
> Thus add support for `MITIGATION_RETHUNK`.
> 
> Without this, `objtool` would warn if enabled for Rust and already warns
> under IBT builds, e.g.:
> 
>     samples/rust/rust_print.o: warning: objtool:
>     _R...init+0xa5c: 'naked' return found in RETHUNK build
> 
> Link: https://github.com/rust-lang/rust/issues/116853 [1]
> Link: https://github.com/rust-lang/rust/pull/116892 [2]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Gary Guo <gary@...yguo.net>

> ---
>  arch/x86/Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index e8214bff1aeb..a1883a30a5d8 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -24,11 +24,15 @@ RETPOLINE_CFLAGS	+= $(call cc-option,-mindirect-branch-cs-prefix)
>  
>  ifdef CONFIG_MITIGATION_RETHUNK
>  RETHUNK_CFLAGS		:= -mfunction-return=thunk-extern
> +RETHUNK_RUSTFLAGS	:= -Zfunction-return=thunk-extern
>  RETPOLINE_CFLAGS	+= $(RETHUNK_CFLAGS)
> +RETPOLINE_RUSTFLAGS	+= $(RETHUNK_RUSTFLAGS)
>  endif
>  
>  export RETHUNK_CFLAGS
> +export RETHUNK_RUSTFLAGS
>  export RETPOLINE_CFLAGS
> +export RETPOLINE_RUSTFLAGS
>  export RETPOLINE_VDSO_CFLAGS
>  
>  # For gcc stack alignment is specified with -mpreferred-stack-boundary,
> @@ -218,6 +222,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
>  # Avoid indirect branches in kernel to deal with Spectre
>  ifdef CONFIG_MITIGATION_RETPOLINE
>    KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
> +  KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS)
>    # Additionally, avoid generating expensive indirect jumps which
>    # are subject to retpolines for small number of switch cases.
>    # LLVM turns off jump table generation by default when under


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ