From 39fe6892fd52faed6325ff7f13a92da01ab35727 Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Mon, 19 Oct 2026 23:34:38 +0000 Subject: rust: hrtimer: declare cfi_encoding for hrtimer_restart The hrtimer callbacks return bindings::hrtimer_restart, which bindgen generates as c_uint. C calls them through hrtimer->function, which returns enum hrtimer_restart. kCFI encodes enum types by name even with integer normalization, so the type ids never match and every call fails the CFI check. Generate hrtimer_restart as a newtype with a cfi_encoding, as is done for lru_status, and adapt HrTimerRestart to the newtype. Fixes: 8a8afe9349fb ("rust: hrtimer: introduce hrtimer support") Signed-off-by: Sami Tolvanen Reviewed-by: Alice Ryhl Reviewed-by: FUJITA Tomonori Tested-by: FUJITA Tomonori Acked-by: Andreas Hindborg Reviewed-by: Gary Guo Acked-by: Danilo Krummrich Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261019-rust-cfi-fixes-v1-2-9503472ba738@google.com Signed-off-by: Miguel Ojeda --- rust/kernel/time/hrtimer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rust/kernel') diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs index 2d7f1131a813..07344ed5fbd5 100644 --- a/rust/kernel/time/hrtimer.rs +++ b/rust/kernel/time/hrtimer.rs @@ -834,14 +834,14 @@ pub unsafe trait HasHrTimer { #[repr(u32)] pub enum HrTimerRestart { /// Timer should not be restarted. - NoRestart = bindings::hrtimer_restart_HRTIMER_NORESTART, + NoRestart = bindings::hrtimer_restart::HRTIMER_NORESTART.0, /// Timer should be restarted. - Restart = bindings::hrtimer_restart_HRTIMER_RESTART, + Restart = bindings::hrtimer_restart::HRTIMER_RESTART.0, } impl HrTimerRestart { fn into_c(self) -> bindings::hrtimer_restart { - self as bindings::hrtimer_restart + bindings::hrtimer_restart(self as c_uint) } } -- cgit v1.2.3