fs/resctrl: Use open-time credentials for task move permission checks
PATCH v2 1/1 fs/resctrl: Use open-time credentials for task move permission checks
Writing a PID to a resctrl group's "tasks" file moves that task into the group. Whether the move is allowed depends on the PID written, so rdtgroup_task_write_permission() checks it at write time, applying the same cred_ids_allow_move() rule as __cgroup1_procs_write().
It checks current's credentials. That may allow a less privileged process to trick a more privileged one into writing into a fd that it opened. Commit 1756d7994ad8 ("cgroup: Use open-time credentials for process migraton perm checks") closed the same hole in cgroup by using the credentials saved at open time. rdtgroup_task_write_permission() still uses current_cred().
Use of->file->f_cred instead, as cgroup1 does.
---
v2:
- Rebased onto commit 27369da9c651 ("fs/resctrl: use cred_ids_allow_move()") in linux-next.
- Dropped the comment change.
v1: https://lore.kernel.org/all/[email protected]/
fs/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/resctrl/rdtgroup.c +1 -1
@@ -725,7 +725,7 @@ static int rdtgroup_task_write_permission(struct task_struct *task, struct kernfs_open_file *of) {const struct cred *tcred =get_task_cred (task); -const struct cred *cred =current_cred (); +const struct cred *cred = of->file->f_cred;int ret =0 ;/*
Signature · 1 line
2.43.0