lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190625142508.GE3419@hirez.programming.kicks-ass.net>
Date:   Tue, 25 Jun 2019 16:25:08 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Qian Cai <cai@....pw>
Cc:     mingo@...hat.com, valentin.schneider@....com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sched/core: silence a warning in sched_init()

On Tue, Jun 25, 2019 at 10:04:19AM -0400, Qian Cai wrote:
> On Tue, 2019-06-25 at 15:52 +0200, Peter Zijlstra wrote:

> Yes, -Wmissing-prototype makes no sense, but "-Wunused-but-set-variable" is
> pretty valid to catch certain developer errors. For example,
> 
> https://lists.linuxfoundation.org/pipermail/iommu/2019-May/035680.html
> 
> > 
> > As to this one, ideally the compiler would not be stupid, and understand
> > the below, but alas.
> 
> Pretty sure that won't work, as the compiler will complain something like,
> 
> ISO C90 forbids mixed declarations and code

No, it builds just fine, it's a new block and C allows new variables at
every block start -- with the scope of that block.

And for our config, alloc_size is an unconditional 0, so it should DCE
the whole block and with that our variable. But clearly the passes are
the other way around :/

> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index fa43ce3962e7..cb652e165570 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -6369,7 +6369,7 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
> >  
> >  void __init sched_init(void)
> >  {
> > -	unsigned long alloc_size = 0, ptr;
> > +	unsigned long alloc_size = 0;
> >  	int i;
> >  
> >  	wait_bit_init();
> > @@ -6381,7 +6381,7 @@ void __init sched_init(void)
> >  	alloc_size += 2 * nr_cpu_ids * sizeof(void **);
> >  #endif
> >  	if (alloc_size) {
> > -		ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
> > +		unsigned long ptr = (unsigned long)kzalloc(alloc_size,
> > GFP_NOWAIT);
> >  
> >  #ifdef CONFIG_FAIR_GROUP_SCHED
> >  		root_task_group.se = (struct sched_entity **)ptr;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ