[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKdAkRS42-qN6wN+kJjnAff2YsFzEDpXW19Tp==aWQbA1Qna8w@mail.gmail.com>
Date: Wed, 5 Oct 2016 12:23:34 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: John Stultz <john.stultz@...aro.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Colin Cross <ccross@...roid.com>, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Jonathan Corbet <corbet@....net>, cgroups@...r.kernel.org,
Android Kernel Team <kernel-team@...roid.com>,
Rom Lemarchand <romlem@...roid.com>,
Dmitry Shmidt <dimitrysh@...gle.com>,
Todd Kjos <tkjos@...gle.com>,
Christian Poetzsch <christian.potzsch@...tec.com>,
Amit Pundir <amit.pundir@...aro.org>,
Ricky Zhou <rickyz@...omium.org>
Subject: Re: [PATCH 1/2] cgroup: Add generic cgroup subsystem permission checks
On Wed, Oct 5, 2016 at 12:16 PM, John Stultz <john.stultz@...aro.org> wrote:
> On Wed, Oct 5, 2016 at 12:09 PM, Dmitry Torokhov
> <dmitry.torokhov@...il.com> wrote:
>> [ Some comments are form Ricky Zhou <rickyz@...omium.org>, some from
>> myself ]
>> On Mon, Oct 03, 2016 at 09:41:29PM -0700, John Stultz wrote:
>>> From: Colin Cross <ccross@...roid.com>
>>>
> [snip]
>>> +
>>> + cset = task_css_set(task);
>>
>> Do we need to take css_set_lock here? If not, why?
>>
>>> + list_add(&cset->mg_node, &tset.src_csets);
>>> + ret = cgroup_allow_attach(dst_cgrp, &tset);
>>> + list_del(&tset.src_csets);
>>
>> This should be
>>
>> list_del_init(&cset->mg_node);
>>
>> since you are deleting task's cset from the tset list, not other way
>> around. It only happen to work because there is exactly 1 member in
>> tset.src_csets and list_del done on it is exactly list_del_init on the
>> node, so you are not leaving with uncorrupted mg_node in task's cset.
>>
>>> + if (ret)
>>> + ret = -EACCES;
>>> + }
>>>
>>> if (!ret && cgroup_on_dfl(dst_cgrp)) {
>>> struct super_block *sb = of->file->f_path.dentry->d_sb;
>>
>> Isn't this, generally speaking, racy? We take current task's cset and
>> check if we have rights to move it over. But we do not have any locking
>> between check and actual move, so can the cset change between these 2
>> operations?
>>
>> And if cset can't really change and it is only 1 task, then why do we
>> bother with forming taskset at all? Can we make allow_attach take just
>> the target task argument?
>
> After Tejun's feedback, I've tried reworking the same functionality in
> a much simpler fashion by introducing a new capability bit.
> https://lkml.org/lkml/2016/10/4/479
>
> I believe that approach doesn't have the drawbacks you've pointed out
> here, but would appreciate your input on it.
>
> As for your feedback on this patch, I'll have to look into it a bit,
> as I don't have good answers for you for you right off. But these do
> seem like valid concerns and since the Android common.git kernels are
> using the code I submitted here, this issues likely need to be fixed
> there.
Yeah, we are looking into the same for ChromeOS, so we have this:
https://chromium-review.googlesource.com/c/393907/
Thanks.
--
Dmitry
Powered by blists - more mailing lists