Skip to contentSkip to conversation

objtool/rust: add one more `noreturn` Rust function

PATCH Applied Miguel Ojeda 4 participants 5 messages Jan 12, 2025 – Feb 12, 2025

Subsystems (3)
lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

PATCH 1/1 objtool/rust: add one more `noreturn` Rust function

Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20), under some kernel configurations with CONFIG_RUST_DEBUG_ASSERTIONS=y, one may trigger a new objtool warning:

rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes() falls through to next function _R...core3ops4drop4Drop4drop()

due to a call to the noreturn symbol:

core::panicking::assert_failed::<usize, usize>

Thus add it to the list so that objtool knows it is actually noreturn. Do so matching with strstr since it is a generic.

See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.

Cc <[email protected]> # Needed in 6.12.y only (Rust is pinned in older LTSs).
---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
index 76060da755b5..e7ec29dfdff2 100644
@@ -218,6 +218,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
 	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
 	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
+	       strstr(func->name, "_4core9panicking13assert_failed")					||
 	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
 	       (strstr(func->name, "_4core5slice5index24slice_") &&
 		str_ends_with(func->name, "_fail"));

base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20

Signature · 1 line
2.48.0
#1 lore raw
Quoted 5 lines · Miguel Ojeda

See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.

Cc <[email protected]> # Needed in 6.12.y only (Rust is pinned in older LTSs).

Greg/Sasha: I didn't add a Fixes since it is not really a "fix" for that commit, but if you want it for automation please feel free to add it:

Fixes 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
Quoted 2 lines
+              strstr(func->name, "_4core9panicking13assert_failed")                                    ||
               strstr(func->name, "_4core9panicking11panic_const24panic_const_")                        ||

Nit: I should have probably put it after this one to keep it sorted.

objtool: happy to take this through the Rust tree or not, as you prefer -- it is not urgent.

Thanks!

Cheers,
Miguel

maintainer
#2 lore raw
Quoted 5 lines · Miguel Ojeda
Quoted 4 lines · Miguel Ojeda

See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.

Quoted 7 lines
Quoted 1 line
Cc <[email protected]> # Needed in 6.12.y only (Rust is pinned in older LTSs).

Greg/Sasha: I didn't add a Fixes since it is not really a "fix" for that commit, but if you want it for automation please feel free to add it:

Fixes 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")

Yeah, putting the Fixes: tag triggers our tools easier, but we can manage either way :)

thanks,

greg k-h

reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to Miguel Ojeda
Quoted 11 lines · On Sun, 12 Jan 2025 15:39:51 +0100 Miguel Ojeda <[email protected]> wrote:

Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20), under some kernel configurations with CONFIG_RUST_DEBUG_ASSERTIONS=y, one may trigger a new objtool warning:

rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes() falls through to next function _R...core3ops4drop4Drop4drop()

due to a call to the noreturn symbol:

core::panicking::assert_failed::<usize, usize>

Quoted 8 lines

Thus add it to the list so that objtool knows it is actually noreturn. Do so matching with strstr since it is a generic.

See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.

Cc <[email protected]> # Needed in 6.12.y only (Rust is pinned in older LTSs).
Quoted 18 lines
---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
index 76060da755b5..e7ec29dfdff2 100644
@@ -218,6 +218,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
 	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
 	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
+	       strstr(func->name, "_4core9panicking13assert_failed")					||
 	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
 	       (strstr(func->name, "_4core5slice5index24slice_") &&
 		str_ends_with(func->name, "_fail"));

base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20

Applied
#4 lore raw
In reply to Miguel Ojeda
Quoted 12 lines · Miguel Ojeda

Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20), under some kernel configurations with CONFIG_RUST_DEBUG_ASSERTIONS=y, one may trigger a new objtool warning:

rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes() falls through to next function _R...core3ops4drop4Drop4drop()

due to a call to the noreturn symbol:

core::panicking::assert_failed::<usize, usize>

Quoted 8 lines

Thus add it to the list so that objtool knows it is actually noreturn. Do so matching with strstr since it is a generic.

See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.

Cc <[email protected]> # Needed in 6.12.y only (Rust is pinned in older LTSs).

Applied to rust-fixes -- thanks everyone!

[ Updated Cc: stable@ to include 6.13.y. - Miguel ]

Cheers,
Miguel