Skip to content

Commit 1fc3444

Browse files
ebiedermgregkh
authored andcommitted
cgroup-v1: Require capabilities to set release_agent
commit 24f6008 upstream. The cgroup release_agent is called with call_usermodehelper. The function call_usermodehelper starts the release_agent with a full set fo capabilities. Therefore require capabilities when setting the release_agaent. Reported-by: Tabitha Sable <tabitha.c.sable@gmail.com> Tested-by: Tabitha Sable <tabitha.c.sable@gmail.com> Fixes: 81a6a5c ("Task Control Groups: automatic userspace notification of idle cgroups") Cc: stable@vger.kernel.org # v2.6.24+ Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ac4ba79 commit 1fc3444

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎kernel/cgroup/cgroup-v1.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,
545545

546546
BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
547547

548+
/*
549+
* Release agent gets called with all capabilities,
550+
* require capabilities to set release agent.
551+
*/
552+
if ((of->file->f_cred->user_ns != &init_user_ns) ||
553+
!capable(CAP_SYS_ADMIN))
554+
return -EPERM;
555+
548556
cgrp = cgroup_kn_lock_live(of->kn, false);
549557
if (!cgrp)
550558
return -ENODEV;
@@ -958,6 +966,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
958966
/* Specifying two release agents is forbidden */
959967
if (ctx->release_agent)
960968
return invalfc(fc, "release_agent respecified");
969+
/*
970+
* Release agent gets called with all capabilities,
971+
* require capabilities to set release agent.
972+
*/
973+
if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN))
974+
return invalfc(fc, "Setting release_agent not allowed");
961975
ctx->release_agent = param->string;
962976
param->string = NULL;
963977
break;

0 commit comments

Comments
 (0)