mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: cgroup-v1: Require capabilities to set release_agent
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:81a6a5cdd2("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> (cherry picked from commit24f6008564) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: If663568d24f781c58c882d69a5b81a9327c0e6fe
This commit is contained in:
committed by
Todd Kjos
parent
7e6f112beb
commit
ee1e2de73c
@@ -548,6 +548,14 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,
|
|||||||
|
|
||||||
BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
|
BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Release agent gets called with all capabilities,
|
||||||
|
* require capabilities to set release agent.
|
||||||
|
*/
|
||||||
|
if ((of->file->f_cred->user_ns != &init_user_ns) ||
|
||||||
|
!capable(CAP_SYS_ADMIN))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
cgrp = cgroup_kn_lock_live(of->kn, false);
|
cgrp = cgroup_kn_lock_live(of->kn, false);
|
||||||
if (!cgrp)
|
if (!cgrp)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@@ -961,6 +969,12 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
|||||||
/* Specifying two release agents is forbidden */
|
/* Specifying two release agents is forbidden */
|
||||||
if (ctx->release_agent)
|
if (ctx->release_agent)
|
||||||
return invalfc(fc, "release_agent respecified");
|
return invalfc(fc, "release_agent respecified");
|
||||||
|
/*
|
||||||
|
* Release agent gets called with all capabilities,
|
||||||
|
* require capabilities to set release agent.
|
||||||
|
*/
|
||||||
|
if ((fc->user_ns != &init_user_ns) || !capable(CAP_SYS_ADMIN))
|
||||||
|
return invalfc(fc, "Setting release_agent not allowed");
|
||||||
ctx->release_agent = param->string;
|
ctx->release_agent = param->string;
|
||||||
param->string = NULL;
|
param->string = NULL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user