mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
@ 2026-06-16 12:30 Alice Ryhl
  2026-06-16 13:34 ` Miguel Ojeda
  2026-06-19  8:01 ` Miguel Ojeda
  0 siblings, 2 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-06-16 12:30 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier, Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Douglas Su,
	Alex Gaynor, Fiona Behrens, Sven Van Asbroeck, Kees Cook,
	Wedson Almeida Filho, linux-kbuild, linux-kernel, rust-for-linux,
	llvm, stable, Alice Ryhl

Due to a rustc bug, the -Cforce-frame-pointers=y flag only emits the
frame-pointer annotation for functions, but not for the module. This
means that functions generated by the LLVM backend such as
'asan.module_ctor' do not receive the frame-pointer annotation.

This is likely to lead to broken backtraces and may also cause issues
with ftrace if these features are used with functions generated by the
LLVM backend.

Thus, use -Zllvm_module_flag to work around this rustc bug if using a
rustc without the fix.

Cc: stable@kernel.org
Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
Link: https://github.com/rust-lang/rust/pull/156980
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 5e73bba74da3..4bfa87e2562a 100644
--- a/Makefile
+++ b/Makefile
@@ -966,6 +966,7 @@ KBUILD_CFLAGS += $(stackp-flags-y)
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
+KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:max)
 else
 # Some targets (ARM with Thumb2, for example), can't be built with frame
 # pointers.  For those, we don't have FUNCTION_TRACER automatically

---
base-commit: 0e0611827f3349d0a2ac121c023a6d3260dcecdb
change-id: 20260616-frame-ptr-fix-1c3733f3c764

Best regards,
-- 
Alice Ryhl <aliceryhl@google.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
  2026-06-16 12:30 [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER Alice Ryhl
@ 2026-06-16 13:34 ` Miguel Ojeda
  2026-06-16 13:41   ` Alice Ryhl
  2026-06-19  8:01 ` Miguel Ojeda
  1 sibling, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2026-06-16 13:34 UTC (permalink / raw)
  To: Alice Ryhl
  Cc: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Douglas Su, Alex Gaynor,
	Fiona Behrens, Sven Van Asbroeck, Kees Cook,
	Wedson Almeida Filho, linux-kbuild, linux-kernel, rust-for-linux,
	llvm, stable

On Tue, Jun 16, 2026 at 2:30 PM Alice Ryhl <aliceryhl@google.com> wrote:
>
> Cc: stable@kernel.org
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")

For 6.1.y, we use Rust 1.62.0, so we don't have `-Zllvm_module_flag`,
so we cannot go that far back. I guess we will need to accept the
issue there.

For 6.6.y, we use Rust 1.73.0, so we don't have it either.

For 6.12.y onward, we support Rust 1.78.0, so it is fine --
`-Zllvm_module_flag` got added in Rust 1.76.0.

In both 6.1.y and 6.6.y, we also don't have `rustc-min-version`,
because the version is pinned there. That part happens to work,
though, just due to how lax Make is... However, if the flag had been
available, then we should probably still do it cleanly with a custom
patch to avoid confusion.

So I will instead do:

Cc: stable@vger.kernel.org # 6.12.y and later (flag not available in
pinned Rust in older LTSs).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
  2026-06-16 13:34 ` Miguel Ojeda
@ 2026-06-16 13:41   ` Alice Ryhl
  0 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-06-16 13:41 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Douglas Su, Alex Gaynor,
	Fiona Behrens, Sven Van Asbroeck, Kees Cook,
	Wedson Almeida Filho, linux-kbuild, linux-kernel, rust-for-linux,
	llvm, stable

On Tue, Jun 16, 2026 at 3:34 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Jun 16, 2026 at 2:30 PM Alice Ryhl <aliceryhl@google.com> wrote:
> >
> > Cc: stable@kernel.org
> > Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
>
> For 6.1.y, we use Rust 1.62.0, so we don't have `-Zllvm_module_flag`,
> so we cannot go that far back. I guess we will need to accept the
> issue there.
>
> For 6.6.y, we use Rust 1.73.0, so we don't have it either.
>
> For 6.12.y onward, we support Rust 1.78.0, so it is fine --
> `-Zllvm_module_flag` got added in Rust 1.76.0.
>
> In both 6.1.y and 6.6.y, we also don't have `rustc-min-version`,
> because the version is pinned there. That part happens to work,
> though, just due to how lax Make is... However, if the flag had been
> available, then we should probably still do it cleanly with a custom
> patch to avoid confusion.
>
> So I will instead do:
>
> Cc: stable@vger.kernel.org # 6.12.y and later (flag not available in
> pinned Rust in older LTSs).

Ah, I didn't know it was so new. That makes sense, thanks.

Alice

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
  2026-06-16 12:30 [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER Alice Ryhl
  2026-06-16 13:34 ` Miguel Ojeda
@ 2026-06-19  8:01 ` Miguel Ojeda
  1 sibling, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2026-06-19  8:01 UTC (permalink / raw)
  To: Alice Ryhl
  Cc: Nathan Chancellor, Nicolas Schier, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Douglas Su, Alex Gaynor,
	Fiona Behrens, Sven Van Asbroeck, Kees Cook,
	Wedson Almeida Filho, linux-kbuild, linux-kernel, rust-for-linux,
	llvm, stable

On Tue, Jun 16, 2026 at 2:30 PM Alice Ryhl <aliceryhl@google.com> wrote:
>
> Due to a rustc bug, the -Cforce-frame-pointers=y flag only emits the
> frame-pointer annotation for functions, but not for the module. This
> means that functions generated by the LLVM backend such as
> 'asan.module_ctor' do not receive the frame-pointer annotation.
>
> This is likely to lead to broken backtraces and may also cause issues
> with ftrace if these features are used with functions generated by the
> LLVM backend.
>
> Thus, use -Zllvm_module_flag to work around this rustc bug if using a
> rustc without the fix.
>
> Cc: stable@kernel.org
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> Link: https://github.com/rust-lang/rust/pull/156980
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>

Applied to `rust-fixes` -- thanks everyone!

    [ The fix [1] has landed for Rust 1.98.0 (expected release on
      2026-08-20). - Miguel ]

    [ - Adjusted Cc: stable@ as discussed.

      - Added comment with link to the PR, similar to what we did in commit
        ac35b5580ace ("rust: arm64: set uwtable llvm module flag for
        CONFIG_UNWIND_TABLES").

        - Miguel ]

By the way, as far as I understand, the `vger.` version of the Cc:
stable@ address is the one that should be used normally:

  Use ``Cc: stable@kernel.org`` instead when fixing unpublished vulnerabilities:
  it reduces the chance of accidentally exposing the fix to the public by way of
  'git send-email', as mails sent to that address are not delivered anywhere.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-19  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16 12:30 [PATCH] rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER Alice Ryhl
2026-06-16 13:34 ` Miguel Ojeda
2026-06-16 13:41   ` Alice Ryhl
2026-06-19  8:01 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®