mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
rust: task: clarify comments on task UID accessors
Linux has separate subjective and objective task credentials, see the comment above `struct cred`. Clarify which accessor functions operate on which set of credentials. Also document that Task::euid() is a very weird operation. You can see how weird it is by grepping for task_euid() in the history - binder was its only user. Task::euid() obtains the objective effective UID - it looks at the credentials of the task for purposes of acting on it as an object, but then accesses the effective UID (which the credentials.7 man page describes as "[...] used by the kernel to determine the permissions that the process will have when accessing shared resources [...]"). For context: Arguably, binder's use of task_euid() is a theoretical security problem, which only has no impact on Android because Android has no setuid binaries executable by apps. commit29bc22ac5e("binder: use euid from cred instead of using task") originally fixed that by removing that only user of task_euid(), but the fix got reverted in commitc21a80ca06("binder: fix test regression due to sender_euid change") because some Android test started failing. It was since fixed again by commit65b6721522("binder: use current_euid() for transaction sender identity"), which uses current_euid() instead. Signed-off-by: Jann Horn <jannh@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
+6
-3
@@ -210,14 +210,17 @@ impl Task {
|
||||
unsafe { *ptr::addr_of!((*self.as_ptr()).pid) }
|
||||
}
|
||||
|
||||
/// Returns the UID of the given task.
|
||||
/// Returns the objective real UID of the given task.
|
||||
#[inline]
|
||||
pub fn uid(&self) -> Kuid {
|
||||
// SAFETY: It's always safe to call `task_uid` on a valid task.
|
||||
Kuid::from_raw(unsafe { bindings::task_uid(self.as_ptr()) })
|
||||
}
|
||||
|
||||
/// Returns the effective UID of the given task.
|
||||
/// Returns the objective effective UID of the given task.
|
||||
///
|
||||
/// You should probably not be using this; the effective UID is normally
|
||||
/// only relevant in subjective credentials.
|
||||
#[inline]
|
||||
pub fn euid(&self) -> Kuid {
|
||||
// SAFETY: It's always safe to call `task_euid` on a valid task.
|
||||
@@ -371,7 +374,7 @@ impl PartialEq for Task {
|
||||
impl Eq for Task {}
|
||||
|
||||
impl Kuid {
|
||||
/// Get the current euid.
|
||||
/// Get the current subjective effective UID.
|
||||
#[inline]
|
||||
pub fn current_euid() -> Kuid {
|
||||
// SAFETY: Just an FFI call.
|
||||
|
||||
Reference in New Issue
Block a user