* [PATCH] cgroup: move a check to parse_cgroupfs_options()
@ 2011-12-22 8:43 Li Zefan
[not found] ` <4EF2EDA7.4010004-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Li Zefan @ 2011-12-22 8:43 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
Always check the validity of mount options in parse_cgroupfs_options().
No functional change.
Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
kernel/cgroup.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4936d88..bdb7994 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1218,7 +1218,6 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
(opts->subsys_bits & mask))
return -EINVAL;
-
/* Can't specify "none" and some subsystems */
if (opts->subsys_bits && opts->none)
return -EINVAL;
@@ -1231,6 +1230,13 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
return -EINVAL;
/*
+ * This can happen only when none of the subsystems is enabled
+ * in the system.
+ */
+ if (!opts->subsys_bits && !opts->none)
+ return -EINVAL;
+
+ /*
* Grab references on all the modules we'll need, so the subsystems
* don't dance around before rebind_subsystems attaches them. This may
* take duplicate reference counts on a subsystem that's already used,
@@ -1401,9 +1407,6 @@ static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts)
{
struct cgroupfs_root *root;
- if (!opts->subsys_bits && !opts->none)
- return NULL;
-
root = kzalloc(sizeof(*root), GFP_KERNEL);
if (!root)
return ERR_PTR(-ENOMEM);
@@ -1442,10 +1445,6 @@ static int cgroup_set_super(struct super_block *sb, void *data)
int ret;
struct cgroup_sb_opts *opts = data;
- /* If we don't have a new root, we can't set up a new sb */
- if (!opts->new_root)
- return -EINVAL;
-
BUG_ON(!opts->subsys_bits && !opts->none);
ret = set_anon_super(sb, NULL);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroup: move a check to parse_cgroupfs_options()
[not found] ` <4EF2EDA7.4010004-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2011-12-22 15:20 ` Tejun Heo
[not found] ` <20111222152011.GA17084-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2011-12-22 15:20 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
Hello,
On Thu, Dec 22, 2011 at 04:43:19PM +0800, Li Zefan wrote:
> Always check the validity of mount options in parse_cgroupfs_options().
>
> No functional change.
>
> Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
> ---
> kernel/cgroup.c | 15 +++++++--------
> 1 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 4936d88..bdb7994 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1218,7 +1218,6 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
> (opts->subsys_bits & mask))
> return -EINVAL;
>
> -
> /* Can't specify "none" and some subsystems */
> if (opts->subsys_bits && opts->none)
> return -EINVAL;
> @@ -1231,6 +1230,13 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
> return -EINVAL;
>
> /*
> + * This can happen only when none of the subsystems is enabled
> + * in the system.
> + */
> + if (!opts->subsys_bits && !opts->none)
> + return -EINVAL;
The three ifs here share a lot and I think sharing the common parts
would make the logic clearer. e.g. The first and this can be easily
combined to (bool)opts->subsys_bits != (bool)opts->none which would
explain the logic better too.
> @@ -1442,10 +1445,6 @@ static int cgroup_set_super(struct super_block *sb, void *data)
> int ret;
> struct cgroup_sb_opts *opts = data;
>
> - /* If we don't have a new root, we can't set up a new sb */
> - if (!opts->new_root)
> - return -EINVAL;
> -
And where did this one go?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroup: move a check to parse_cgroupfs_options()
[not found] ` <20111222152011.GA17084-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
@ 2011-12-23 3:40 ` Li Zefan
[not found] ` <4EF3F834.0-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Li Zefan @ 2011-12-23 3:40 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
于 2011年12月22日 23:20, Tejun Heo 写道:
> Hello,
>
> On Thu, Dec 22, 2011 at 04:43:19PM +0800, Li Zefan wrote:
>> Always check the validity of mount options in parse_cgroupfs_options().
>>
>> No functional change.
>>
>> Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
>> ---
>> kernel/cgroup.c | 15 +++++++--------
>> 1 files changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
>> index 4936d88..bdb7994 100644
>> --- a/kernel/cgroup.c
>> +++ b/kernel/cgroup.c
>> @@ -1218,7 +1218,6 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
>> (opts->subsys_bits & mask))
>> return -EINVAL;
>>
>> -
>> /* Can't specify "none" and some subsystems */
>> if (opts->subsys_bits && opts->none)
>> return -EINVAL;
>> @@ -1231,6 +1230,13 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
>> return -EINVAL;
>>
>> /*
>> + * This can happen only when none of the subsystems is enabled
>> + * in the system.
>> + */
>> + if (!opts->subsys_bits && !opts->none)
>> + return -EINVAL;
>
> The three ifs here share a lot and I think sharing the common parts
> would make the logic clearer. e.g. The first and this can be easily
> combined to (bool)opts->subsys_bits != (bool)opts->none which would
> explain the logic better too.
>
ok.
>> @@ -1442,10 +1445,6 @@ static int cgroup_set_super(struct super_block *sb, void *data)
>> int ret;
>> struct cgroup_sb_opts *opts = data;
>>
>> - /* If we don't have a new root, we can't set up a new sb */
>> - if (!opts->new_root)
>> - return -EINVAL;
>> -
>
> And where did this one go?
>
The other one I removed sets opts->new_root to NULL, and this one detects
the NULL ptr:
if (!opts->subsys_bits && !opts->none)
return NULL;
...
opts->new_root = NULL;
...
if (!opts->new_root)
return -EINVAL;
shortcut to:
if (!opts->subsys_bits && !opts->none)
return -EINVAL;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroup: move a check to parse_cgroupfs_options()
[not found] ` <4EF3F834.0-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2011-12-23 22:52 ` Tejun Heo
[not found] ` <CAOS58YMffJ4uH02H0TH_DmhtjQOVgz2_u_6HJqsGnR6PQ3ZGzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2011-12-23 22:52 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
Hello,
On Thu, Dec 22, 2011 at 7:40 PM, Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:
>> And where did this one go?
>
> The other one I removed sets opts->new_root to NULL, and this one detects
> the NULL ptr:
>
> if (!opts->subsys_bits && !opts->none)
> return NULL;
> ...
> opts->new_root = NULL;
> ...
> if (!opts->new_root)
> return -EINVAL;
>
> shortcut to:
>
> if (!opts->subsys_bits && !opts->none)
> return -EINVAL;
Thanks for the explanation. Maybe explaining it briefly in the commit
message would be nice?
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroup: move a check to parse_cgroupfs_options()
[not found] ` <CAOS58YMffJ4uH02H0TH_DmhtjQOVgz2_u_6HJqsGnR6PQ3ZGzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-12-27 1:48 ` Li Zefan
0 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2011-12-27 1:48 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
Tejun Heo wrote:
> Hello,
>
> On Thu, Dec 22, 2011 at 7:40 PM, Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:
>>> And where did this one go?
>>
>> The other one I removed sets opts->new_root to NULL, and this one detects
>> the NULL ptr:
>>
>> if (!opts->subsys_bits && !opts->none)
>> return NULL;
>> ...
>> opts->new_root = NULL;
>> ...
>> if (!opts->new_root)
>> return -EINVAL;
>>
>> shortcut to:
>>
>> if (!opts->subsys_bits && !opts->none)
>> return -EINVAL;
>
> Thanks for the explanation. Maybe explaining it briefly in the commit
> message would be nice?
>
I recalled why we have this check in this place, that is to allow mounting
by hierarchy name, but it has been broken for a long time. I'll send a
fix with detailed changelog.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-27 1:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22 8:43 [PATCH] cgroup: move a check to parse_cgroupfs_options() Li Zefan
[not found] ` <4EF2EDA7.4010004-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2011-12-22 15:20 ` Tejun Heo
[not found] ` <20111222152011.GA17084-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2011-12-23 3:40 ` Li Zefan
[not found] ` <4EF3F834.0-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2011-12-23 22:52 ` Tejun Heo
[not found] ` <CAOS58YMffJ4uH02H0TH_DmhtjQOVgz2_u_6HJqsGnR6PQ3ZGzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-27 1:48 ` Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).