| c37adf34 | 21-Aug-2025 |
Onur Özkan <work@onurozkan.dev> |
rust: file: use to_result for error handling
Simplifies error handling by replacing the manual check of the return value with the `to_result` helper.
Signed-off-by: Onur Özkan <work@onurozkan.dev>
rust: file: use to_result for error handling
Simplifies error handling by replacing the manual check of the return value with the `to_result` helper.
Signed-off-by: Onur Özkan <work@onurozkan.dev> Link: https://lore.kernel.org/20250821091001.28563-1-work@onurozkan.dev Signed-off-by: Christian Brauner <brauner@kernel.org>
show more ...
|
| dc35ddcf | 15-Jun-2025 |
Tamir Duberstein <tamird@gmail.com> |
rust: enable `clippy::ref_as_ptr` lint
In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]:
> Using `as` casts may result in silently changing mutability or type.
While this doesn't elimin
rust: enable `clippy::ref_as_ptr` lint
In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]:
> Using `as` casts may result in silently changing mutability or type.
While this doesn't eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint -- no functional change intended.
Link: https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr [1] Suggested-by: Benno Lossin <benno.lossin@proton.me> Link: https://lore.kernel.org/all/D8PGG7NTWB6U.3SS3A5LN4XWMN@proton.me/ Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-6-f43b024581e8@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 946026ba | 27-May-2025 |
Pekka Ristola <pekkarr@protonmail.com> |
rust: file: improve safety comments
Some of the safety comments in `LocalFile`'s methods incorrectly refer to the `File` type instead of `LocalFile`, so fix them to use the correct type.
Also add m
rust: file: improve safety comments
Some of the safety comments in `LocalFile`'s methods incorrectly refer to the `File` type instead of `LocalFile`, so fix them to use the correct type.
Also add missing Markdown code spans around lifetimes in the safety comments, i.e. change 'a to `'a`.
Link: https://github.com/Rust-for-Linux/linux/issues/1165 Signed-off-by: Pekka Ristola <pekkarr@protonmail.com> Link: https://lore.kernel.org/20250527204636.12573-2-pekkarr@protonmail.com Reviewed-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
show more ...
|
| 5da9857b | 15-Sep-2024 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: file: add `FileDescriptorReservation`
Allow for the creation of a file descriptor in two steps: first, we reserve a slot for it, then we commit or drop the reservation. The first step may fail
rust: file: add `FileDescriptorReservation`
Allow for the creation of a file descriptor in two steps: first, we reserve a slot for it, then we commit or drop the reservation. The first step may fail (e.g., the current process ran out of available slots), but commit and drop never fail (and are mutually exclusive).
This is needed by Rust Binder when fds are sent from one process to another. It has to be a two-step process to properly handle the case where multiple fds are sent: The operation must fail or succeed atomically, which we achieve by first reserving the fds we need, and only installing the files once we have reserved enough fds to send the files.
Fd reservations assume that the value of `current` does not change between the call to get_unused_fd_flags and the call to fd_install (or put_unused_fd). By not implementing the Send trait, this abstraction ensures that the `FileDescriptorReservation` cannot be moved into a different process.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Co-developed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20240915-alice-file-v10-6-88484f7a3dcf@google.com Signed-off-by: Christian Brauner <brauner@kernel.org>
show more ...
|
| a3df991d | 15-Sep-2024 |
Wedson Almeida Filho <wedsonaf@gmail.com> |
rust: cred: add Rust abstraction for `struct cred`
Add a wrapper around `struct cred` called `Credential`, and provide functionality to get the `Credential` associated with a `File`.
Rust Binder mu
rust: cred: add Rust abstraction for `struct cred`
Add a wrapper around `struct cred` called `Credential`, and provide functionality to get the `Credential` associated with a `File`.
Rust Binder must check the credentials of processes when they attempt to perform various operations, and these checks usually take a `&Credential` as parameter. The security_binder_set_context_mgr function would be one example. This patch is necessary to access these security_* methods from Rust.
This Rust abstraction makes the following assumptions about the C side: * `struct cred` is refcounted with `get_cred`/`put_cred`. * It's okay to transfer a `struct cred` across threads, that is, you do not need to call `put_cred` on the same thread as where you called `get_cred`. * The `euid` field of a `struct cred` never changes after initialization. * The `f_cred` field of a `struct file` never changes after initialization.
Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com> Co-developed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20240915-alice-file-v10-4-88484f7a3dcf@google.com Reviewed-by: Kees Cook <kees@kernel.org> Reviewed-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
show more ...
|