All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, bblum@andrew.cmu.edu,
	fweisbec@gmail.com, lizf@cn.fujitsu.com, paul@paulmenage.org,
	tj@kernel.org
Subject: Re: + cgroups-fix-ordering-of-calls-in-cgroup_attach_proc.patch added to -mm tree
Date: Fri, 26 Aug 2011 17:12:45 +0200	[thread overview]
Message-ID: <20110826151245.GA16243@redhat.com> (raw)
In-Reply-To: <201108252044.p7PKiaHd006997@imap1.linux-foundation.org>

On 08/25, Andrew Morton wrote:
>
> From: Ben Blum <bblum@andrew.cmu.edu>
>
> @@ -2135,14 +2135,17 @@ int cgroup_attach_proc(struct cgroup *cg
>  		oldcgrp = task_cgroup_from_root(tsk, root);
>  		if (cgrp == oldcgrp)
>  			continue;
> -		/* attach each task to each subsystem */
> -		for_each_subsys(root, ss) {
> -			if (ss->attach_task)
> -				ss->attach_task(cgrp, tsk);
> -		}
>  		/* if the thread is PF_EXITING, it can just get skipped. */
>  		retval = cgroup_task_migrate(cgrp, oldcgrp, tsk, true);
> -		BUG_ON(retval != 0 && retval != -ESRCH);
> +		if (retval == 0) {
> +			/* attach each task to each subsystem */
> +			for_each_subsys(root, ss) {
> +				if (ss->attach_task)
> +					ss->attach_task(cgrp, tsk);
> +			}

Yes, I think this is what we need, the patch itself looks fine.



But this doesn't answer my another question. After that the code does

	 * step 4: do expensive, non-thread-specific subsystem callbacks.

		ss->attach(ss, cgrp, oldcgrp, leader);

OK, non-thread-specific is nice, but how can this "leader" represent
the process?

It can be zombie (but still group_leader) even without any races.
Say, cpuset_attach() and mem_cgroup_move_task() need get_task_mm(p).
How this can work if the leader is dead?

Also. Even if we add the locking around while_each_thread() (btw,
we need this in any case), we can race with exec which can change
the leader. In this case this task_struct has nothing to do with
the process we are going to attach, at all.

And, ss->can_attach(leader) has the same problems, it seems.




And. Say, devcgroup_can_attach() checks CAP_SYS_ADMIN. This is
security check. Why it is enough to check the leader only? We are
going to attach all threads. OK, this is probably fine, and I never
understood why capable/creds are not per-process, but this looks
so strange.

Oleg.


  reply	other threads:[~2011-08-26 15:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 20:44 + cgroups-fix-ordering-of-calls-in-cgroup_attach_proc.patch added to -mm tree akpm
2011-08-26 15:12 ` Oleg Nesterov [this message]
2011-08-26 15:18   ` Paul Menage
2011-08-26 15:21   ` Tejun Heo
2011-08-26 15:50     ` Oleg Nesterov
2011-08-26 15:38 ` [PATCH v2] cgroups: Don't attach task to subsystem if migration failed Frederic Weisbecker
2011-08-26 17:01   ` Ben Blum
  -- strict thread matches above, loose matches on Subject: below --
2011-08-26 19:27 + cgroups-fix-ordering-of-calls-in-cgroup_attach_proc.patch added to -mm tree akpm

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=20110826151245.GA16243@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bblum@andrew.cmu.edu \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=paul@paulmenage.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.