Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1212417
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] cgroup: get a ref to source csses when migrating |
| Date | 2015-08-24 20:50 +0200 |
| Message-ID | <q14YF-7E8-5@gated-at.bofh.it> (permalink) |
| References | <q0Czn-HK-5@gated-at.bofh.it> <q0DlL-1Rq-3@gated-at.bofh.it> <q0DlN-1Rq-33@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, Aug 23, 2015 at 11:10:31PM +1000, Aleksa Sarai wrote:
> Grab a ref to each source css being migrated from, otherwise it's
> possible for the refcount to reach zero between ->can_attach() and
> ->cancel_attach(). This means that operations on the task's old css
> (such as container_of(...)) become unsafe, as we may be operating on a
> different css.
>
> Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
> ---
> kernel/cgroup.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 4ec1b7ee5de8..6cbfbe36284d 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -2305,6 +2305,17 @@ static int cgroup_migrate(struct cgroup *cgrp, struct task_struct *leader,
> if (list_empty(&tset.src_csets))
> return 0;
>
> + /*
> + * Fetch a ref of each css, so that the old task's css doesn't get reaped
> + * between ->can_attach() and ->cancel_attach().
> + */
> + down_read(&css_set_rwsem);
> + list_for_each_entry(cset, &tset.src_csets, mg_node) {
> + for_each_e_css(css, i, cgrp)
> + css_get(cset->subsys[i]);
> + }
> + up_read(&css_set_rwsem);
Have you verified that the scenario you're describing can actually
happen? AFAICS, cgroup_migrate_add_src() already does the pinning.
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RE: Bad Reference Semantics in PIDs Controller. Aleksa Sarai <cyphar@cyphar.com> - 2015-08-23 14:30 +0200
Re: [PATCH 0/2] cgroup: pids: fix invalid reference semantics Aleksa Sarai <cyphar@cyphar.com> - 2015-08-23 15:20 +0200
[PATCH 1/2] cgroup: get a ref to source csses when migrating Aleksa Sarai <cyphar@cyphar.com> - 2015-08-23 15:20 +0200
Re: [PATCH 1/2] cgroup: get a ref to source csses when migrating Tejun Heo <tj@kernel.org> - 2015-08-24 20:50 +0200
Re: [PATCH 1/2] cgroup: get a ref to source csses when migrating Aleksa Sarai <cyphar@cyphar.com> - 2015-08-25 04:10 +0200
Re: [PATCH 1/2] cgroup: get a ref to source csses when migrating Tejun Heo <tj@kernel.org> - 2015-08-25 20:20 +0200
[PATCH 0/2] cgroup: pids: fix invalid reference semantics Aleksa Sarai <cyphar@cyphar.com> - 2015-08-23 15:20 +0200
[PATCH 2/2] cgroup: pids: fix invalid get/put usage Aleksa Sarai <cyphar@cyphar.com> - 2015-08-23 15:20 +0200
Re: [PATCH 2/2] cgroup: pids: fix invalid get/put usage Tejun Heo <tj@kernel.org> - 2015-08-24 21:10 +0200
csiph-web