Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1283631
| From | Xunlei Pang <xlpang@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() |
| Date | 2015-12-04 09:30 +0100 |
| Message-ID | <qBTUD-dS-13@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <qBis3-19N-29@gated-at.bofh.it> <qBs81-7iq-7@gated-at.bofh.it> <qBxr4-2rt-21@gated-at.bofh.it> <qBAIi-4rp-21@gated-at.bofh.it> <qBTBf-7g-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Ingo,
On 12/04/2015 at 04:09 PM, Ingo Molnar wrote:
> * Xunlei Pang <xlpang@redhat.com> wrote:
>
>>> Hm, is the alloc_cpumask_var() done in alloc_sched_domains() safe?
>> Until now, I haven't found any other similar issues, but I will check further.
>>
>>> At least the usage pattern in init_sched_domains() looks unsafe:
>>>
>>> doms_cur = alloc_sched_domains(ndoms_cur);
>>> if (!doms_cur)
>>> doms_cur = &fallback_doms;
>>> cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map);
> So is this pattern in init_sched_domains() correct, for OFFSTACK=y?
>
> It looks wrong to me, as alloc_sched_domains() allocates an uninitialized cpumask
> via alloc_cpumask_var() and returns it:
>
> cpumask_var_t *alloc_sched_domains(unsigned int ndoms)
> {
> int i;
> cpumask_var_t *doms;
>
> doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL);
> if (!doms)
> return NULL;
> for (i = 0; i < ndoms; i++) {
> if (!alloc_cpumask_var(&doms[i], GFP_KERNEL)) {
> free_sched_domains(doms, i);
> return NULL;
> }
> }
> return doms;
> }
>
> and then this code:
>
>>> cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map);
> uses it without first clearing it.
>
> So is this another such bug, or am I missing something?
Yeah, I noticed that as well. But fortunately cpumask_andnot(),
cpumask_and() and the like will clear doms_cur[] indirectly, also
cpu_isolated_map, cpu_active_mask, etc doesn't contain any
garbage bits. I also checked the use of it by cpuset, no extra such
bug found by me so far.
Regards,
Xunlei
>
> Thanks,
>
> Ingo
> --
> 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/
--
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
[PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Xunlei Pang <xlpang@redhat.com> - 2015-12-02 13:00 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Peter Zijlstra <peterz@infradead.org> - 2015-12-02 13:40 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Xunlei Pang <xlpang@redhat.com> - 2015-12-02 14:20 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Peter Zijlstra <peterz@infradead.org> - 2015-12-02 17:30 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Xunlei Pang <xlpang@redhat.com> - 2015-12-03 03:50 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Ingo Molnar <mingo@kernel.org> - 2015-12-03 09:30 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Xunlei Pang <xlpang@redhat.com> - 2015-12-03 13:00 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Ingo Molnar <mingo@kernel.org> - 2015-12-04 09:10 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Peter Zijlstra <peterz@infradead.org> - 2015-12-04 09:30 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Ingo Molnar <mingo@kernel.org> - 2015-12-04 09:40 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Xunlei Pang <xlpang@redhat.com> - 2015-12-04 09:30 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Ingo Molnar <mingo@kernel.org> - 2015-12-04 09:40 +0100
Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() Peter Zijlstra <peterz@infradead.org> - 2015-12-03 10:40 +0100
[tip:locking/core] sched/core: Clear the root_domain cpumasks in init_rootdomain() tip-bot for Xunlei Pang <tipbot@zytor.com> - 2015-12-04 13:00 +0100
csiph-web