[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiq72mstzYHbQa-M1Z_zWoLsBOPsA8kPstsuRO2G0NDnnTxCQ@mail.gmail.com>
Date: Sun, 29 Jun 2025 21:31:34 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
Marcelo Moreira <marcelomoreira1905@...il.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] revocable: rust: document why &T is not used in RevocableGuard
On Thu, Jun 12, 2025 at 1:17 PM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> When a reference appears in a function argument, the reference is
> assumed to be valid for the entire duration of that function call; this
> is called a stack protector [1]. Because of that, custom pointer types
> whose destructor may invalidate the pointee (i.e. they are more similar
> to Box<T> than &T) cannot internally use a reference, and must instead
> use a raw pointer.
>
> This issue is something that is often missed during unsafe review. For
> examples, see [2] and [3]. To ensure that people don't try to simplify
> RevocableGuard by changing the raw pointer to a reference, add a comment
> to that effect.
>
> Link: https://perso.crans.org/vanille/treebor/protectors.html [1]
> Link: https://users.rust-lang.org/t/unsafe-code-review-semi-owning-weak-rwlock-t-guard/95706 [2]
> Link: https://lore.kernel.org/all/aEqdur4JTFa1V20U@google.com/ [3]
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
Applied to `rust-next` -- thanks everyone!
[ Adjusted title. - Miguel ]
Cheers,
Miguel
Powered by blists - more mailing lists