binder+rust_binder: use current_euid() for transaction sender identity
Subsystems (2)
cover binder+rust_binder: use current_euid() for transaction sender identity
Based on the discussion on
<https://lore.kernel.org/all/[email protected]/>,
here's a proposed change to binder to stop looking at objective EUIDs.
This removes the last remaining users of Task::euid() (in Rust), and the only remaining caller to task_euid() is the now-unused Rust wrapper.
(Sidenote: It might be worth considering whether it really makes sense to have functions like current_euid(), task_euid(), and so on in Rust - it might be less messy to just expose current_cred() and (if necessary) get_task_cred(), and then use the Credential abstraction around struct cred to access the various UID/GID/... fields.)
(build-tested only.)
---
Jann Horn (2):
binder: use current_euid() for transaction sender identity
rust_binder: use current_euid() for transaction sender identity
drivers/android/binder.c | 2 +- drivers/android/binder/transaction.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
---
base-commit: 3c4ae63073d84abee5d81ce46d86a94e9dae9c89
change-id: 20260213-binder-uid-a24ede5026a8
Signature · 1 line
Jann Horn <[email protected]>
PATCH 1/2 binder: use current_euid() for transaction sender identity
Binder currently uses task_euid(proc->tsk) as the transaction sender EUID, where proc->tsk is the main thread of the process that opened /dev/binder. That's not clean; use the subjective EUID of the current task instead.
--- drivers/android/binder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +1 -1
@@ -3113,7 +3113,7 @@ static void binder_transaction(struct binder_proc *proc, t->start_time = t_start_time; t->from_pid = proc->pid; t->from_tid = thread->pid; - t->sender_euid =task_euid (proc->tsk); + t->sender_euid =current_euid (); t->code = tr->code; t->flags = tr->flags; t->priority =task_nice (current);
Signature · 1 line
2.53.0.273.g2a3d683680-goog
PATCH 2/2 rust_binder: use current_euid() for transaction sender identity
In reply to Jann HornBinder currently uses from.process.task.euid() as the transaction sender EUID, where from.process.task is the main thread of the process that opened /dev/binder. That's not clean; use the subjective EUID of the current task instead.
--- drivers/android/binder/transaction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder/transaction.rs +2 -2
@@ -107,7 +107,7 @@ pub(crate) fn new( debug_id, target_node: Some(target_node), from_parent, - sender_euid: from.process.task.euid(), + sender_euid: Kuid::current_euid(), from: from.clone(), to, code: trd.code,
@@ -147,7 +147,7 @@ pub(crate) fn new_reply( debug_id, target_node: None, from_parent: None, - sender_euid: from.process.task.euid(), + sender_euid: Kuid::current_euid(), from: from.clone(), to, code: trd.code,
Signature · 1 line
2.53.0.273.g2a3d683680-goog
Quoted 6 lines · Jann Horn
Based on the discussion on
<https://lore.kernel.org/all/[email protected]/>,
here's a proposed change to binder to stop looking at objective EUIDs.This removes the last remaining users of
Task::euid()(in Rust), and the only remaining caller totask_euid()is the now-unused Rust wrapper.
Any chance you could include a patch to remove the now-unused method?
Quoted 5 lines
(Sidenote: It might be worth considering whether it really makes sense to have functions like
current_euid(),task_euid(), and so on in Rust - it might be less messy to just exposecurrent_cred()and (if necessary)get_task_cred(), and then use theCredentialabstraction aroundstruct credto access the various UID/GID/... fields.)
We could add a cred() method to CurrentTask and do this:
current!().cred().euid()
Quoted 1 line
Signed-off-by Jann Horn <[email protected]>
Quoted 13 lines · Jann Horn
Based on the discussion on
<https://lore.kernel.org/all/[email protected]/>,
here's a proposed change to binder to stop looking at objective EUIDs.This removes the last remaining users of
Task::euid()(in Rust), and the only remaining caller totask_euid()is the now-unused Rust wrapper.(Sidenote: It might be worth considering whether it really makes sense to have functions like
current_euid(),task_euid(), and so on in Rust - it might be less messy to just exposecurrent_cred()and (if necessary)get_task_cred(), and then use theCredentialabstraction aroundstruct credto access the various UID/GID/... fields.)
Quoted 3 lines
(build-tested only.)
Signed-off-by Jann Horn <[email protected]>
Quoted 14 lines
---
Jann Horn (2):
binder: usecurrent_euid()for transaction sender identity
rust_binder: usecurrent_euid()for transaction sender identitydrivers/android/binder.c | 2 +- drivers/android/binder/transaction.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)---
base-commit:3c4ae63073d84abee5d81ce46d86a94e9dae9c89
change-id: 20260213-binder-uid-a24ede5026a8--
Jann Horn <[email protected]>