linux/rust/kernel
Alice Ryhl 8ad1a41f7e
rust: file: add Kuid wrapper
Adds a wrapper around `kuid_t` called `Kuid`. This allows us to define
various operations on kuids such as equality and current_euid. It also
lets us provide conversions from kuid into userspace values.

Rust Binder needs these operations because it needs to compare kuids for
equality, and it needs to tell userspace about the pid and uid of
incoming transactions.

To read kuids from a `struct task_struct`, you must currently use
various #defines that perform the appropriate field access under an RCU
read lock. Currently, we do not have a Rust wrapper for rcu_read_lock,
which means that for this patch, there are two ways forward:

 1. Inline the methods into Rust code, and use __rcu_read_lock directly
    rather than the rcu_read_lock wrapper. This gives up lockdep for
    these usages of RCU.

 2. Wrap the various #defines in helpers and call the helpers from Rust.

This patch uses the second option. One possible disadvantage of the
second option is the possible introduction of speculation gadgets, but
as discussed in [1], the risk appears to be acceptable.

Of course, once a wrapper for rcu_read_lock is available, it is
preferable to use that over either of the two above approaches.

Link: https://lore.kernel.org/all/202312080947.674CD2DC7@keescook/ [1]
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Trevor Gross <tmgross@umich.edu>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20240915-alice-file-v10-7-88484f7a3dcf@google.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-09-30 13:02:29 +02:00
..
alloc rust: avoid box_uninit_write feature 2024-09-04 23:11:31 +02:00
block rust: block: do not use removed queue flag API 2024-06-20 06:54:48 -06:00
fs rust: file: add FileDescriptorReservation 2024-09-30 13:02:29 +02:00
init rust: init: add assert_pinned macro 2024-08-23 06:25:59 +02:00
list rust: list: add ListArcField 2024-08-23 06:26:57 +02:00
net Rust changes for v6.10 2024-05-13 15:13:54 -07:00
sync rust: types: add NotThreadSafe 2024-09-30 13:02:27 +02:00
alloc.rs rust: add abstraction for struct page 2024-07-08 23:44:01 +02:00
block.rs rust: block: introduce kernel::block::mq module 2024-06-14 07:45:04 -06:00
build_assert.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
cred.rs rust: file: add Kuid wrapper 2024-09-30 13:02:29 +02:00
device.rs device: rust: improve safety comments 2024-06-20 16:14:58 +02:00
error.rs rust: error: allow useless_conversion for 32-bit builds 2024-08-18 23:10:53 +02:00
firmware.rs rust: firmware: fix invalid rustdoc link 2024-07-31 13:24:29 +02:00
fs.rs rust: file: add Rust abstraction for struct file 2024-09-30 13:02:28 +02:00
init.rs rust: init: add assert_pinned macro 2024-08-23 06:25:59 +02:00
ioctl.rs rust: kernel: mark code fragments in docs with backticks 2024-02-18 21:22:27 +01:00
kunit.rs rust: support srctree-relative links 2023-12-21 20:54:17 +01:00
lib.rs rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
list.rs rust: list: add ListArcField 2024-08-23 06:26:57 +02:00
net.rs rust: core abstractions for network PHY drivers 2023-12-15 09:35:50 +00:00
page.rs rust: add abstraction for struct page 2024-07-08 23:44:01 +02:00
prelude.rs rust: init: add write_[pin_]init functions 2024-08-22 00:16:16 +02:00
print.rs rust: kernel: use docs.kernel.org links in code documentation 2024-08-25 14:44:34 +02:00
rbtree.rs rust: avoid box_uninit_write feature 2024-09-04 23:11:31 +02:00
security.rs rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: kernel: use docs.kernel.org links in code documentation 2024-08-25 14:44:34 +02:00
str.rs rust: kernel: remove redundant imports 2024-05-05 19:22:25 +02:00
sync.rs rust: sync: implement Default for LockClassKey 2024-05-05 19:22:25 +02:00
task.rs rust: file: add Kuid wrapper 2024-09-30 13:02:29 +02:00
time.rs rust: time: doc: Add missing C header links 2024-05-01 00:04:47 +02:00
types.rs rust: types: add NotThreadSafe 2024-09-30 13:02:27 +02:00
uaccess.rs rust: uaccess: add typed accessors for userspace pointers 2024-07-08 23:44:01 +02:00
workqueue.rs rust: kernel: make impl_has_work compatible with more generics 2024-07-08 22:39:39 +02:00