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: <CAH5fLgijS7JOO==JQegexPEgx3hs8hFDcQqFa4L50F1LdfZJJQ@mail.gmail.com>
Date: Thu, 21 Nov 2024 15:39:45 +0100
From: Alice Ryhl <aliceryhl@...gle.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Matthew Wilcox <willy@...radead.org>, 
	Vlastimil Babka <vbabka@...e.cz>, John Hubbard <jhubbard@...dia.com>, 
	"Liam R. Howlett" <Liam.Howlett@...cle.com>, Andrew Morton <akpm@...ux-foundation.org>, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Arnd Bergmann <arnd@...db.de>, 
	Christian Brauner <brauner@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, 
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
	Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
	Benno Lossin <benno.lossin@...ton.me>, linux-kernel@...r.kernel.org, linux-mm@...ck.org, 
	rust-for-linux@...r.kernel.org, Andreas Hindborg <a.hindborg@...nel.org>
Subject: Re: [PATCH v8 2/7] mm: rust: add vm_area_struct methods that require
 read access

On Thu, Nov 21, 2024 at 1:50 PM Lorenzo Stoakes
<lorenzo.stoakes@...cle.com> wrote:
>
> On Thu, Nov 21, 2024 at 11:23:39AM +0100, Alice Ryhl wrote:
> > On Wed, Nov 20, 2024 at 8:07 PM Lorenzo Stoakes
> > <lorenzo.stoakes@...cle.com> wrote:
> > >
> > > On Wed, Nov 20, 2024 at 02:49:56PM +0000, Alice Ryhl wrote:
> > > > +    #[inline]
> > > > +    pub fn end(&self) -> usize {
> > > > +        // SAFETY: By the type invariants, the caller holds at least the mmap read lock, so this
> > > > +        // access is not a data race.
> > > > +        unsafe { (*self.as_ptr()).__bindgen_anon_1.__bindgen_anon_1.vm_end as _ }
> > > > +    }
> > > > +
> > > > +    /// Unmap pages in the given page range.
> > >
> > > This needs some more description, as 'unmapping' pages is unfortunately an
> > > overloaded term in the kernel and this very much might confuse people as
> > > opposed to e.g. munmap()'ing a range.
> > >
> > > I'd say something like 'clear page table mappings for the range at the leaf
> > > level, leaving all other page tables intact, freeing any memory referenced
> > > by the VMA in this range (anonymous memory is completely freed, file-backed
> > > memory has its reference count on page cache folio's dropped, any dirty
> > > data will still be written back to disk as usual)'.
> >
> > Sure, will add that to the docs.
>
> Thanks, I assume you mean this comment, which will form part of the docs? As
> here we should at least replace the 'unmap' with 'zap' to avoid confusion
> vs. munmap().

Yes. Comments with three slashes are rendered in the html documentation.

> > > > +    #[inline]
> > > > +    pub fn zap_page_range_single(&self, address: usize, size: usize) {
> > > > +        // SAFETY: By the type invariants, the caller has read access to this VMA, which is
> > > > +        // sufficient for this method call. This method has no requirements on the vma flags. Any
> > > > +        // value of `address` and `size` is allowed.
> > > > +        unsafe {
> > > > +            bindings::zap_page_range_single(
> > >
> > > Hm weirdly I see this in rust/bindings/bindings_generated.rs but not in
> > > rust/helpers/mm.c is this intended?
> > >
> > > Is this meant to be generated _from_ somewhere? Is something missing for
> > > that?
> >
> > The bindings_generated.rs file is generated at built-time from C
> > headers. The zap_page_range_single is a real function, not a fake
> > static inline header-only function, so bindgen is able to generate it
> > without anything in rust/helpers.
> >
> > > > +                self.as_ptr(),
> > > > +                address as _,
> > > > +                size as _,
> > > > +                core::ptr::null_mut(),
> > > > +            )
> > > > +        };
> > > > +    }
> > > > +}
> > > > +
> > > > +/// The integer type used for vma flags.
> > > > +#[doc(inline)]
> > > > +pub use bindings::vm_flags_t;
> > >
> > > Where do you declare this type?
> >
> > It's declared in include/linux/mm_types.h
>
> I meant from a rust perspective, but I guess bindgen handles this?

Yes, anything in `bindings::` is output from bindgen based on C headers.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ