mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
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: 8a8afe9349 ("rust: hrtimer: introduce hrtimer support")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Tested-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261019-rust-cfi-fixes-v1-2-9503472ba738@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
01f3e6b4b1
commit
39fe6892fd
|
|
@ -27,6 +27,8 @@
|
|||
--opaque-type spinlock
|
||||
|
||||
# enums that appear in indirect function calls should specify a cfi type
|
||||
--newtype-enum hrtimer_restart
|
||||
--with-attribute-custom-enum=hrtimer_restart='#[cfi_encoding="15hrtimer_restart"]'
|
||||
--newtype-enum irqreturn
|
||||
--with-attribute-custom-enum=irqreturn='#[cfi_encoding="9irqreturn"]'
|
||||
--newtype-enum lru_status
|
||||
|
|
|
|||
|
|
@ -834,14 +834,14 @@ unsafe fn start(this: *const Self, expires: <Self::TimerMode as HrTimerMode>::Ex
|
|||
#[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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user