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]
Message-ID: <ZrOIsLH2JsoFzCZB@boqun-archlinux>
Date: Wed, 7 Aug 2024 07:46:08 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Benno Lossin <benno.lossin@...ton.me>, 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>,
	Peter Zijlstra <peterz@...radead.org>,
	Alexander Viro <viro@...iv.linux.org.uk>,
	Christian Brauner <brauner@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Arve Hjønnevåg <arve@...roid.com>,
	Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
	Joel Fernandes <joel@...lfernandes.org>,
	Carlos Llamas <cmllamas@...gle.com>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Dan Williams <dan.j.williams@...el.com>,
	Matthew Wilcox <willy@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>, Daniel Xu <dxu@...uu.xyz>,
	Martin Rodriguez Reboredo <yakoyoku@...il.com>,
	Trevor Gross <tmgross@...ch.edu>, linux-kernel@...r.kernel.org,
	rust-for-linux@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	Kees Cook <kees@...nel.org>
Subject: Re: [PATCH v8 3/8] rust: file: add Rust abstraction for `struct file`

On Wed, Aug 07, 2024 at 10:50:32AM +0200, Alice Ryhl wrote:
> On Tue, Aug 6, 2024 at 9:30 PM Boqun Feng <boqun.feng@...il.com> wrote:
> >
> > On Tue, Aug 06, 2024 at 10:48:11AM +0200, Alice Ryhl wrote:
> > [...]
> > > > > +    /// Returns the flags associated with the file.
> > > > > +    ///
> > > > > +    /// The flags are a combination of the constants in [`flags`].
> > > > > +    #[inline]
> > > > > +    pub fn flags(&self) -> u32 {
> > > > > +        // This `read_volatile` is intended to correspond to a READ_ONCE call.
> > > > > +        //
> > > > > +        // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount.
> > > > > +        //
> > > > > +        // FIXME(read_once): Replace with `read_once` when available on the Rust side.
> > > >
> > > > Do you know the status of this?
> > >
> > > It's still unavailable.
> > >
> >
> > I think with our own Atomic API, we can just use atomic_read() here:
> > yes, I know that to make this is not a UB, we need the C side to also do
> > atomic write on this `f_flags`, however, my reading of C code seems to
> > suggest that FS relies on writes to this field is atomic, therefore
> > unless someone is willing to convert all writes to `f_flags` in C into
> > a WRITE_ONCE(), nothing more we can do on Rust side. So using
> > atomic_read() is the correct thing to begin with.
> 
> Huh? The C side uses atomic reads for this?
> 

Well, READ_ONCE(->f_flags) is atomic, so I thought you want to use
atomic here. However, after a quick look of `->f_flags` accesses, I find
out they should be protected by `->f_lock` (a few cases rely on
data race accesses, see p4_fd_open()), so I think what you should really
do here is the similar: make sure Rust code only accesses `->f_flags`
if `->f_lock` is held. Unless that's not the case for binder?

Regards,
Boqun

> Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ