]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: Use open-time credentials for process migraton perm checks
authorTejun Heo <tj@kernel.org>
Thu, 6 Jan 2022 21:02:28 +0000 (11:02 -1000)
committerTejun Heo <tj@kernel.org>
Thu, 6 Jan 2022 21:02:28 +0000 (11:02 -1000)
commit44fe8782723d64eda9364553c167946388be297b
treea18dad688da376a60325e2d1ee34187f16a50bde
parent72b2dd17ce82b88b28b5a5a29dd4c34aff62e783
cgroup: Use open-time credentials for process migraton perm checks

cgroup process migration permission checks are performed at write time as
whether a given operation is allowed or not is dependent on the content of
the write - the PID. This currently uses current's credentials which is a
potential security weakness as it may allow scenarios where a less
privileged process tricks a more privileged one into writing into a fd that
it created.

This patch makes both cgroup2 and cgroup1 process migration interfaces to
use the credentials saved at the time of open (file->f_cred) instead of
current's.

Reported-by: "Eric W. Biederman" <ebiederm@xmission.com>
Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Fixes: 025979bc8fa2 ("cgroup: require write perm on common ancestor when moving processes on the default hierarchy")
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c