[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH5fLgi4YNsLHFoKw7UsGbmpEaqeG4o5yMQAodZ1KwfExAPL3w@mail.gmail.com>
Date: Tue, 1 Oct 2024 12:57:47 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Trevor Gross <tmgross@...ch.edu>
Cc: Miguel Ojeda <ojeda@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kees Cook <kees@...nel.org>, 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>, Andreas Hindborg <a.hindborg@...sung.com>,
Carlos Llamas <cmllamas@...gle.com>, rust-for-linux@...r.kernel.org,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] rust: harden index manipulation using ownership
On Mon, Sep 30, 2024 at 1:16 AM Trevor Gross <tmgross@...ch.edu> wrote:
>
> On Fri, Sep 13, 2024 at 5:01 PM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> > +//! Utilities for working with ranges of indices.
> > +
> > +/// A range of indices.
> > +///
> > +/// This utility is useful for ensuring that no index in the range is used more than once.
> > +#[derive(Debug)]
> > +pub struct Range {
> > + offset: usize,
> > + length: usize,
> > +}
>
> Would a name like "DataRange" or "CheckedRange" be better here, to
> avoid confusion with core::ops::Range?
Probably a good idea. I've had collisions on those types.
> > + /// Use this range of indices.
> > + ///
> > + /// This destroys the `Range` object, so these indices cannot be used again after this call.
> > + pub fn use_range(self) -> UsedRange {
>
> Maybe just `.use()`?
Makes sense to me.
> > + /// Assert that this range is aligned properly.
> > + pub fn assert_aligned(&self, alignment: usize) -> Result<(), RangeError> {
>
> It would probably be good to warn that this alignment is relative to
> the offset, i.e. if you split a range at an unaligned point then this
> may not be useful.
>
> This is a pretty cool API idea.
Thanks!
Alice
Powered by blists - more mailing lists