All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Zefan Li <lizefan@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: <hannes@cmpxchg.org>, <cgroups@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel-team@fb.com>
Subject: Re: [PATCH 3/4] cgroup: require write perm on common ancestor when moving processes on the default hierarchy
Date: Thu, 18 Jun 2015 11:14:38 +0800	[thread overview]
Message-ID: <5582379E.1050508@huawei.com> (raw)
In-Reply-To: <1434481817-32001-4-git-send-email-tj@kernel.org>

Hi Tejun,

> -static int cgroup_procs_write_permission(struct task_struct *task)
> +static int cgroup_procs_write_permission(struct task_struct *task,
> +					 struct cgroup *dst_cgrp,
> +					 struct kernfs_open_file *of)
>  {
>  	const struct cred *cred = current_cred();
>  	const struct cred *tcred = get_task_cred(task);
> @@ -2407,6 +2409,26 @@ static int cgroup_procs_write_permission(struct task_struct *task)
>  	    !uid_eq(cred->euid, tcred->suid))
>  		ret = -EACCES;
>  
> +	if (cgroup_on_dfl(dst_cgrp)) {

if (!ret && cgroup_on_dfl(dst_cgrp))

> +		struct super_block *sb = of->file->f_path.dentry->d_sb;
> +		struct cgroup *cgrp;
> +		struct inode *inode;
> +
> +		down_read(&css_set_rwsem);
> +		cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
> +		up_read(&css_set_rwsem);
> +
> +		while (!cgroup_is_descendant(dst_cgrp, cgrp))
> +			cgrp = cgroup_parent(cgrp);
> +
> +		ret = -ENOMEM;
> +		inode = kernfs_get_inode(sb, cgrp->procs_kn);
> +		if (inode) {
> +			ret = inode_permission(inode, MAY_WRITE);
> +			iput(inode);
> +		}
> +	}
> +
>  	put_cred(tcred);
>  	return ret;
>  }


WARNING: multiple messages have this Message-ID (diff)
From: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	kernel-team-b10kYP2dOMg@public.gmane.org
Subject: Re: [PATCH 3/4] cgroup: require write perm on common ancestor when moving processes on the default hierarchy
Date: Thu, 18 Jun 2015 11:14:38 +0800	[thread overview]
Message-ID: <5582379E.1050508@huawei.com> (raw)
In-Reply-To: <1434481817-32001-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Hi Tejun,

> -static int cgroup_procs_write_permission(struct task_struct *task)
> +static int cgroup_procs_write_permission(struct task_struct *task,
> +					 struct cgroup *dst_cgrp,
> +					 struct kernfs_open_file *of)
>  {
>  	const struct cred *cred = current_cred();
>  	const struct cred *tcred = get_task_cred(task);
> @@ -2407,6 +2409,26 @@ static int cgroup_procs_write_permission(struct task_struct *task)
>  	    !uid_eq(cred->euid, tcred->suid))
>  		ret = -EACCES;
>  
> +	if (cgroup_on_dfl(dst_cgrp)) {

if (!ret && cgroup_on_dfl(dst_cgrp))

> +		struct super_block *sb = of->file->f_path.dentry->d_sb;
> +		struct cgroup *cgrp;
> +		struct inode *inode;
> +
> +		down_read(&css_set_rwsem);
> +		cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
> +		up_read(&css_set_rwsem);
> +
> +		while (!cgroup_is_descendant(dst_cgrp, cgrp))
> +			cgrp = cgroup_parent(cgrp);
> +
> +		ret = -ENOMEM;
> +		inode = kernfs_get_inode(sb, cgrp->procs_kn);
> +		if (inode) {
> +			ret = inode_permission(inode, MAY_WRITE);
> +			iput(inode);
> +		}
> +	}
> +
>  	put_cred(tcred);
>  	return ret;
>  }

  reply	other threads:[~2015-06-18  3:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16 19:10 [PATCHSET cgroup/for-4.2] cgroup: require write perm on common ancestor for migration Tejun Heo
2015-06-16 19:10 ` Tejun Heo
2015-06-16 19:10 ` [PATCH 1/4] kernfs: make kernfs_get_inode() public Tejun Heo
2015-06-16 19:10   ` Tejun Heo
2015-06-16 20:58   ` Greg Kroah-Hartman
2015-06-16 20:58     ` Greg Kroah-Hartman
2015-06-16 19:10 ` [PATCH 2/4] cgroup: separate out cgroup_procs_write_permission() from __cgroup_procs_write() Tejun Heo
2015-06-16 19:10   ` Tejun Heo
2015-06-16 19:10 ` [PATCH 3/4] cgroup: require write perm on common ancestor when moving processes on the default hierarchy Tejun Heo
2015-06-16 19:10   ` Tejun Heo
2015-06-18  3:14   ` Zefan Li [this message]
2015-06-18  3:14     ` Zefan Li
2015-06-18 17:59     ` Tejun Heo
2015-06-18 17:59   ` [PATCH v2 " Tejun Heo
2015-06-18 19:04     ` Johannes Weiner
2015-06-18 19:04       ` Johannes Weiner
2015-06-16 19:10 ` [PATCH 4/4] cgroup: add delegation section to unified hierarchy documentation Tejun Heo
2015-06-16 19:10   ` Tejun Heo
2015-06-18 19:01   ` Johannes Weiner
2015-06-18 19:01     ` Johannes Weiner
2015-06-18 20:23   ` [PATCH v2 " Tejun Heo
2015-06-18 20:23     ` Tejun Heo
2015-06-18 20:46     ` Johannes Weiner
2015-06-18 20:46       ` Johannes Weiner
2015-06-18 20:55 ` [PATCHSET cgroup/for-4.2] cgroup: require write perm on common ancestor for migration Tejun Heo
2015-06-18 20:55   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5582379E.1050508@huawei.com \
    --to=lizefan@huawei.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.