Delete task_euid()
Subsystems (5)
Alice Ryhl
reviewerv4 cover Delete task_euid()
The task_euid() method is a very weird method, and Binder was the only user. As of commit 65b672152289 ("binder: use current_euid() for transaction sender identity") Binder doesn't use task_euid() anymore, so we can delete this method.
My suggestion would be to merge this through the LSM tree.
---
Changes in v4:
- Reword 'euid' -> 'effective UID' in 'Kuid::current_euid()' docs.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Include 'task' clarification commit in series.
- Rebase and resend.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Update translation as per Alex Shi.
- Pick up Reviewed-by Gary.
- Update commit title to use cred: prefix.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Alice Ryhl (1):
cred: delete task_euid()
Jann Horn (1):
rust: task: clarify comments on task UID accessors
Documentation/security/credentials.rst | 6 ++---- Documentation/translations/zh_CN/security/credentials.rst | 4 +--- include/linux/cred.h | 1 - rust/helpers/task.c | 5 ----- rust/kernel/task.rs | 11 ++--------- 5 files changed, 5 insertions(+), 22 deletions(-)
---
base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
change-id: 20260219-remove-task-euid-19e4b00beebe
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
reviewerPATCH v4 1/2 rust: task: clarify comments on task UID accessors
From: Jann Horn <[email protected]>
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() - binder is 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.
commit 29bc22ac5e5b ("binder: use euid from cred instead of using task") fixed that by removing that only user of task_euid(), but the fix got reverted in commit c21a80ca0684 ("binder: fix test regression due to sender_euid change") because some Android test started failing.
---
Originally sent as:
https://lore.kernel.org/r/[email protected]
--- rust/kernel/task.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
rust/kernel/task.rs +6 -3
@@ -210,14 +210,17 @@ pub fn pid(&self) -> Pid {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 @@ fn eq(&self, other: &Self) -> bool {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.
Signature · 1 line
2.54.0.823.g6e5bcc1fc9-goog
Alice Ryhl
reviewerPATCH v4 2/2 cred: delete task_euid()
In reply to Alice Ryhltask_euid() is a very weird operation. You can see how weird it is by grepping for task_euid() - binder is 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 [...]").
Since usage in Binder has now been removed, get rid of the resulting dead code.
Changes to the zh_CN translation was carried out with the help of Gemini and Google Translate, and since adjusted as per Alex Shi's feedback.
--- Documentation/security/credentials.rst | 6 ++---- Documentation/translations/zh_CN/security/credentials.rst | 4 +--- include/linux/cred.h | 1 - rust/helpers/task.c | 5 ----- rust/kernel/task.rs | 10 ---------- 5 files changed, 3 insertions(+), 23 deletions(-)
Documentation/security/credentials.rst +2 -4
@@ -393,16 +393,14 @@ the credentials so obtained when they're finished with. The result of ``__task_cred()`` should not be passed directly to ``get_cred()`` as this may race with ``commit_cred()``. -There are a couple of convenience functions to access bits of another task's -credentials, hiding the RCU magic from the caller:: +There is a convenience function to access bits of another task's credentials, +hiding the RCU magic from the caller:: uid_t task_uid(task) Task's real UID - uid_t task_euid(task) Task's effective UID If the caller is holding the RCU read lock at the time anyway, then:: __task_cred(task)->uid - __task_cred(task)->euid should be used instead. Similarly, if multiple aspects of a task's credentials need to be accessed, RCU read lock should be used, ``__task_cred()`` called,
Documentation/translations/zh_CN/security/credentials.rst +1 -3
@@ -337,15 +337,13 @@ const指针上操作,因此不需要进行类型转换,但需要临时放弃 ``__task_cred()`` 的结果不应直接传递给 ``get_cred()`` , 因为这可能与 ``commit_cred()`` 发生竞争条件。 -还有一些方便的函数可以访问另一个任务凭据的特定部分,将RCU操作对调用方隐藏起来:: +有一个方便的函数可用于访问另一个任务凭据的特定部分,从而对调用方隐藏RCU机制:: uid_t task_uid(task) Task's real UID - uid_t task_euid(task) Task's effective UID 如果调用方在此时已经持有RCU读锁,则应使用:: __task_cred(task)->uid - __task_cred(task)->euid 类似地,如果需要访问任务凭据的多个方面,应使用RCU读锁,调用 ``__task_cred()`` 函数,将结果存储在临时指针中,然后从临时指针中调用凭据的各个方面,最后释放锁。
include/linux/cred.h +0 -1
@@ -371,7 +371,6 @@ DEFINE_FREE(put_cred, struct cred *, if (!IS_ERR_OR_NULL(_T)) put_cred(_T)) })#define task_uid (task) (task_cred_xxx((task), uid)) -#define task_euid (task) (task_cred_xxx((task), euid))#define task_ucounts (task) (task_cred_xxx((task), ucounts))#define current_cred_xxx (xxx) \
rust/helpers/task.c +0 -5
@@ -28,11 +28,6 @@ __rust_helper kuid_t rust_helper_task_uid(struct task_struct *task)return task_uid (task); } -__rust_helper kuid_t rust_helper_task_euid(struct task_struct *task) -{ -return task_euid (task); -} -#ifndef CONFIG_USER_NS __rust_helper uid_t rust_helper_from_kuid(struct user_namespace *to, kuid_t uid) {
rust/kernel/task.rs +0 -10
@@ -217,16 +217,6 @@ pub fn uid(&self) -> Kuid {Kuid ::from_raw (unsafe { bindings::task_uid (self.as_ptr ()) }) } -/// 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. -Kuid ::from_raw (unsafe { bindings::task_euid (self.as_ptr ()) }) - } -/// Determines whether the given task has pending signals. #[inline] pub fn signal_pending (&self) ->bool {
Signature · 1 line
2.54.0.823.g6e5bcc1fc9-goog
Re: [PATCH v4 1/2] rust: task: clarify comments on task UID accessors
In reply to Alice RyhlQuoted 23 lines · Alice Ryhl
From: Jann Horn <[email protected]>
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 fortask_euid()- binder is 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 oftask_euid()is a theoretical security problem, which only has no impact on Android because Android has no setuid binaries executable by apps.
commit29bc22ac5e5b("binder: use euid from cred instead of using task") fixed that by removing that only user oftask_euid(), but the fix got reverted in commitc21a80ca0684("binder: fix test regression due tosender_euidchange") because some Android test started failing.
Quoted 2 lines
Signed-off-by Jann Horn <[email protected]>Signed-off-by Alice Ryhl <[email protected]>
Quoted 6 lines
---
Originally sent as:
https://lore.kernel.org/r/[email protected]--- rust/kernel/task.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Paul Moore
maintainerQuoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.
Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using task_euid(); it currently reads like it is still being used.
Signature · 1 line
paul-moore.com
Alice Ryhl
reviewerQuoted 11 lines · Paul Moore
Quoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Sure, that makes sense. I'll resend after the merge window.
Quoted 5 lines
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using
task_euid(); it currently reads like it is still being used.
I guess this occurred because when patch 1 was written, it really *was* still being used. Perhaps we could pick up only patch 1 now since even if we run into problems and Binder has to go back to using task_euid(), clarifying the docs is still useful.
Alice
Paul Moore
maintainerQuoted 8 lines · Alice Ryhl
Quoted 7 lines · Paul Moore
Quoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.
Quoted 6 lines
Quoted 4 lines
Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Sure, that makes sense. I'll resend after the merge window.
No need to resend if there are no changes (see below), it's in patchwork and I'm tracking it so you're all set. I'll send another notice when I merge it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using
task_euid(); it currently reads like it is still being used.I guess this occurred because when patch 1 was written, it really *was* still being used.
Yeah, I understand the world has changed since patch 1/2 was written, which is okay, we just need to update the commit description ... which should be a trivial task.
Quoted 3 lines
Perhaps we could pick up only patch 1 now since even
if we run into problems and Binder has to go back to usingtask_euid(), clarifying the docs is still useful.
I assumed that was one of the reasons for splitting the changes across two patches (reverting patch 2/2 leaves patch 1/2 intact). Regardless, we're at -rc6 and with patch 1/2 being purely a comment update I don't see an urgent rush on this, especially considering that if I did pick it up now, it would be for the v7.2 merge window and the binder/current_euid() change will ship in v7.1.
Let's update the commit description - you've got a couple of weeks to do that - and then we'll merge everything once the v7.2 merge window closes.
Signature · 1 line
paul-moore.com
Alice Ryhl
reviewerQuoted 45 lines · Paul Moore
Quoted 8 lines · Alice Ryhl
Quoted 7 lines · Paul Moore
Quoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.Quoted 6 lines
Quoted 4 lines
Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Sure, that makes sense. I'll resend after the merge window.
No need to resend if there are no changes (see below), it's in patchwork and I'm tracking it so you're all set. I'll send another notice when I merge it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using
task_euid(); it currently reads like it is still being used.I guess this occurred because when patch 1 was written, it really *was* still being used.
Yeah, I understand the world has changed since patch 1/2 was written, which is okay, we just need to update the commit description ... which should be a trivial task.
Quoted 3 lines
Perhaps we could pick up only patch 1 now since even
if we run into problems and Binder has to go back to usingtask_euid(), clarifying the docs is still useful.I assumed that was one of the reasons for splitting the changes across two patches (reverting patch 2/2 leaves patch 1/2 intact). Regardless, we're at -rc6 and with patch 1/2 being purely a comment update I don't see an urgent rush on this, especially considering that if I did pick it up now, it would be for the v7.2 merge window and the binder/current_euid() change will ship in v7.1.
Quoted 3 lines
Let's update the commit description - you've got a couple of weeks to do that - and then we'll merge everything once the v7.2 merge window closes.
Sounds good, thanks!
Alice
Paul Moore
maintainerQuoted 46 lines · Alice Ryhl
Quoted 45 lines · Paul Moore
Quoted 8 lines · Alice Ryhl
Quoted 7 lines · Paul Moore
Quoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.Quoted 6 lines
Quoted 4 lines
Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Sure, that makes sense. I'll resend after the merge window.
No need to resend if there are no changes (see below), it's in patchwork and I'm tracking it so you're all set. I'll send another notice when I merge it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using
task_euid(); it currently reads like it is still being used.I guess this occurred because when patch 1 was written, it really *was* still being used.
Yeah, I understand the world has changed since patch 1/2 was written, which is okay, we just need to update the commit description ... which should be a trivial task.
Quoted 3 lines
Perhaps we could pick up only patch 1 now since even
if we run into problems and Binder has to go back to usingtask_euid(), clarifying the docs is still useful.I assumed that was one of the reasons for splitting the changes across two patches (reverting patch 2/2 leaves patch 1/2 intact). Regardless, we're at -rc6 and with patch 1/2 being purely a comment update I don't see an urgent rush on this, especially considering that if I did pick it up now, it would be for the v7.2 merge window and the binder/current_euid() change will ship in v7.1.
Quoted 5 lines
Quoted 3 lines
Let's update the commit description - you've got a couple of weeks to do that - and then we'll merge everything once the v7.2 merge window closes.
Sounds good, thanks!
Just wanted to check in and see if this is still on your todo list? No rush, we are only at -rc1, but I was reminded of this while merging other patches and just wanted to check ;)
Signature · 1 line
paul-moore.com
Alice Ryhl
reviewerQuoted 51 lines · Paul Moore
Quoted 50 lines · Alice Ryhl
Quoted 48 lines · Paul Moore
Quoted 8 lines · Alice Ryhl
Quoted 7 lines · Paul Moore
Quoted 5 lines · Alice Ryhl
The
task_euid()method is a very weird method, and Binder was the only user. As of commit65b672152289("binder: usecurrent_euid()for transaction sender identity") Binder doesn't usetask_euid()anymore, so we can delete this method.Quoted 6 lines
Quoted 4 lines
Given the problems from last time, it seems like it might be prudent to let the commit have some time to "breathe" in a proper release, I'd suggest merging this not for the upcoming v7.2 merge window but instead waiting for v7.3.
Sure, that makes sense. I'll resend after the merge window.
No need to resend if there are no changes (see below), it's in patchwork and I'm tracking it so you're all set. I'll send another notice when I merge it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
My suggestion would be to merge this through the LSM tree.
That's fine with me. I'd also suggest updating the commit description in patch 1/2 to indicate that binder is no longer using
task_euid(); it currently reads like it is still being used.I guess this occurred because when patch 1 was written, it really *was* still being used.
Yeah, I understand the world has changed since patch 1/2 was written, which is okay, we just need to update the commit description ... which should be a trivial task.
Quoted 3 lines
Perhaps we could pick up only patch 1 now since even
if we run into problems and Binder has to go back to usingtask_euid(), clarifying the docs is still useful.I assumed that was one of the reasons for splitting the changes across two patches (reverting patch 2/2 leaves patch 1/2 intact). Regardless, we're at -rc6 and with patch 1/2 being purely a comment update I don't see an urgent rush on this, especially considering that if I did pick it up now, it would be for the v7.2 merge window and the binder/current_euid() change will ship in v7.1.
Let's update the commit description - you've got a couple of weeks to do that - and then we'll merge everything once the v7.2 merge window closes.
Quoted 5 lines
Quoted 1 line
Sounds good, thanks!
Just wanted to check in and see if this is still on your todo list? No rush, we are only at -rc1, but I was reminded of this while merging other patches and just wanted to check ;)
Resent!
Alice