Skip to content
Commit 49957f8e authored by Tejun Heo's avatar Tejun Heo
Browse files

cgroup: newly created dirs and files should be owned by the creator

While converting cgroup to kernfs, 2bd59d48

 ("cgroup: convert to
kernfs") accidentally dropped the logic which makes newly created
cgroup dirs and files owned by the current uid / gid.  This broke
cases where cgroup subtree management is delegated to !root as the sub
manager wouldn't be able to create more than single level of hierarchy
or put tasks into child cgroups it created.

Among other things, this breaks user session management in systemd and
one of the symptoms was 90s hang during shutdown.  User session
systemd running as the user creates a sub-service to initiate shutdown
and tries to put kill(1) into it but fails because cgroup.procs is
owned by root.  This leads to 90s hang during shutdown.

Implement cgroup_kn_set_ugid() which sets a kn's uid and gid to those
of the caller and use it from file and dir creation paths.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c6b3d5bc
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment