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] [day] [month] [year] [list]
Message-Id: <cdb12bc6-2372-43b3-b4e9-a1e31e5f9903@app.fastmail.com>
Date: Wed, 18 Jun 2025 17:28:45 -0700
From: "Boqun Feng" <boqun.feng@...il.com>
To: "FUJITA Tomonori" <fujita.tomonori@...il.com>,
 "Andreas Hindborg" <a.hindborg@...nel.org>, alex.gaynor@...il.com,
 "Miguel Ojeda" <ojeda@...nel.org>
Cc: "Alice Ryhl" <aliceryhl@...gle.com>,
 "Anna-Maria Gleixner" <anna-maria@...utronix.de>, bjorn3_gh@...tonmail.com,
 "Danilo Krummrich" <dakr@...nel.org>,
 "Frederic Weisbecker" <frederic@...nel.org>, "Gary Guo" <gary@...yguo.net>,
 "John Stultz" <jstultz@...gle.com>, linux-kernel@...r.kernel.org,
 lossin@...nel.org, "Lyude Paul" <lyude@...hat.com>,
 rust-for-linux@...r.kernel.org, "Stephen Boyd" <sboyd@...nel.org>,
 "Thomas Gleixner" <tglx@...utronix.de>, "Trevor Gross" <tmgross@...ch.edu>
Subject: Re: [PATCH] rust: time: Seal the HrTimerMode trait



On Tue, Jun 17, 2025, at 4:28 PM, FUJITA Tomonori wrote:
> Prevent downstream crates or drivers from implementing `HrTimerMode`
> for arbitrary types, which could otherwise leads to unsupported
> behavior.
>
> Introduce a `private::Sealed` trait and implement it for all types
> that implement `HrTimerMode`.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>

Reviewed-by: Boqun Feng <boqun.feng@...il.com>

Thanks!

Regards,
Boqun

> ---
>  rust/kernel/time/hrtimer.rs | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
> index a6468bc50e57..0028720cb4e9 100644
> --- a/rust/kernel/time/hrtimer.rs
> +++ b/rust/kernel/time/hrtimer.rs
> @@ -442,8 +442,27 @@ fn into_nanos(self) -> i64 {
>      }
>  }
> 
> +mod private {
> +    use crate::time::ClockSource;
> +
> +    pub trait Sealed {}
> +
> +    impl<C: ClockSource> Sealed for super::AbsoluteMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativeMode<C> {}
> +    impl<C: ClockSource> Sealed for super::AbsolutePinnedMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativePinnedMode<C> {}
> +    impl<C: ClockSource> Sealed for super::AbsoluteSoftMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativeSoftMode<C> {}
> +    impl<C: ClockSource> Sealed for super::AbsolutePinnedSoftMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativePinnedSoftMode<C> {}
> +    impl<C: ClockSource> Sealed for super::AbsoluteHardMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativeHardMode<C> {}
> +    impl<C: ClockSource> Sealed for super::AbsolutePinnedHardMode<C> {}
> +    impl<C: ClockSource> Sealed for super::RelativePinnedHardMode<C> {}
> +}
> +
>  /// Operational mode of [`HrTimer`].
> -pub trait HrTimerMode {
> +pub trait HrTimerMode: private::Sealed {
>      /// The C representation of hrtimer mode.
>      const C_MODE: bindings::hrtimer_mode;
> 
>
> base-commit: 994393295c89711531583f6de8f296a30b0d944a
> -- 
> 2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ