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: <23a73a6f-160d-4d06-8d45-ec77293ff258@ryhl.io>
Date: Tue, 15 Oct 2024 20:37:36 +0200
From: Alice Ryhl <alice@...l.io>
To: Boqun Feng <boqun.feng@...il.com>, Alice Ryhl <aliceryhl@...gle.com>
Cc: Christian Brauner <brauner@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
 Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>,
 Alex Gaynor <alex.gaynor@...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@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
 linux-fsdevel@...r.kernel.org, rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: task: adjust safety comments in Task methods

On 10/15/24 8:24 PM, Boqun Feng wrote:
> On Tue, Oct 15, 2024 at 02:02:12PM +0000, Alice Ryhl wrote:
>> The `Task` struct has several safety comments that aren't so great. For
>> example, the reason that it's okay to read the `pid` is that the field
>> is immutable, so there is no data race, which is not what the safety
>> comment says.
>>
>> Thus, improve the safety comments. Also add an `as_ptr` helper. This
>> makes it easier to read the various accessors on Task, as `self.0` may
>> be confusing syntax for new Rust users.
>>
>> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
>> ---
>> This is based on top of vfs.rust.file as the file series adds some new
>> task methods. Christian, can you take this through that tree?
>> ---
>>   rust/kernel/task.rs | 43 ++++++++++++++++++++++++-------------------
>>   1 file changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
>> index 1a36a9f19368..080599075875 100644
>> --- a/rust/kernel/task.rs
>> +++ b/rust/kernel/task.rs
>> @@ -145,11 +145,17 @@ fn deref(&self) -> &Self::Target {
>>           }
>>       }
>>   
>> +    /// Returns a raw pointer to the task.
>> +    #[inline]
>> +    pub fn as_ptr(&self) -> *mut bindings::task_struct {
> 
> FWIW, I think the name convention is `as_raw()` for a wrapper type of
> `Opaque<T>` to return `*mut T`, e.g. `kernel::device::Device`.
> 
> Otherwise this looks good to me.
Both names are in use. See e.g. Page and File that use as_ptr.

In fact, I was asked to change the name on File *to* as_ptr.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ