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] [thread-next>] [day] [month] [year] [list]
Date: Tue, 26 Mar 2024 12:21:34 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Benno Lossin <benno.lossin@...ton.me>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
	Thomas Gleixner <tglx@...utronix.de>,
	Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Wedson Almeida Filho <wedsonaf@...il.com>,
	Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Andreas Hindborg <a.hindborg@...sung.com>,
	John Stultz <jstultz@...gle.com>, Stephen Boyd <sboyd@...nel.org>,
	Valentin Obst <kernel@...entinobst.de>,
	Heghedus Razvan <heghedus.razvan@...tonmail.com>,
	Asahi Lina <lina@...hilina.net>
Subject: Re: [PATCH 4/5] rust: time: Support reading CLOCK_MONOTONIC

On Tue, Mar 26, 2024 at 05:03:41PM +0000, Benno Lossin wrote:
> On 24.03.24 23:33, Boqun Feng wrote:
> > Rust Binder will need to read CLOCK_MONOTONIC to compute how many
> > milliseconds a transaction has been active for when dumping the current
> > state of the Binder driver. This replicates the logic in C Binder [1].
> > 
> > For a usage example in Rust Binder, see [2].
> > 
> > Hence add the support for CLOCK_MONOTONIC read.
> > 
> > The `ktime_get` method cannot be safely called in NMI context. This
> > requirement is not checked by these abstractions, but it is intended
> > that klint [3] or a similar tool will be used to check it in the future.
> > 
> > Link: https://lore.kernel.org/lkml/5ac8c0d09392290be789423f0dd78a520b830fab.1682333709.git.zhangchuang3@xiaomi.com/ [1]
> > Link: https://r.android.com/3004103 [2]
> > Link: https://rust-for-linux.com/klint [3]
> > Co-developed-by: Heghedus Razvan <heghedus.razvan@...tonmail.com>
> > Signed-off-by: Heghedus Razvan <heghedus.razvan@...tonmail.com>
> > Co-developed-by: Asahi Lina <lina@...hilina.net>
> > Signed-off-by: Asahi Lina <lina@...hilina.net>
> > Co-developed-by: Alice Ryhl <aliceryhl@...gle.com>
> > Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> > Signed-off-by: Boqun Feng <boqun.feng@...il.com>
> 
> With the nit fixed:
> 
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> 

Thanks!

> > ---
> > @Alice, I still put the link to the usage of Android binder here, if you
> > want to remove that, please let me know.
> > 
> >  rust/kernel/time.rs | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
> > index 0f9f5605ed48..5cd669cbea01 100644
> > --- a/rust/kernel/time.rs
> > +++ b/rust/kernel/time.rs
> > @@ -113,3 +113,22 @@ fn sub(self, other: Self) -> Self::Output {
> >          Duration::new(self.inner.wrapping_sub(other.inner))
> >      }
> >  }
> > +
> > +/// Contains the various clock source types available to the kernel.
> > +pub mod clock {
> > +    use super::*;
> > +
> > +    /// A clock representing the default kernel time source (`CLOCK_MONOTONIC`).
> > +    pub struct KernelTime;
> > +
> > +    /// `CLOCK_MONOTONIC` is monotonic.
> > +    impl Monotonic for KernelTime {}
> > +
> > +    impl Clock for KernelTime {
> > +        #[inline]
> > +        fn now() -> Instant<Self> {
> > +            // SAFETY: It is always safe to call `ktime_get` outside of NMI context.
> > +            Instant::<Self>::new(unsafe { bindings::ktime_get() })
> 
> I don't think the turbofish syntax (the `::<Self>` part) is needed here.
> 

Fixed locally.

Regards,
Boqun

> -- 
> Cheers,
> Benno
> 
> > +        }
> > +    }
> > +}
> > --
> > 2.44.0
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ