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] [day] [month] [year] [list]
Date:   Mon, 27 Mar 2017 09:10:16 +0000
From:   Nicholas Mc Guire <der.herr@...r.at>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Rusty Russell <rusty@...tcorp.com.au>,
        Nick Piggin <npiggin@...e.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/core: switch to BUG_ON()

On Mon, Mar 27, 2017 at 10:24:40AM +0200, Peter Zijlstra wrote:
> On Mon, Mar 27, 2017 at 09:40:46AM +0200, Nicholas Mc Guire wrote:
> 
> > Found by coccinelle: bugon.cocci
> > ./kernel/sched/core.c:5913:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.
> 
> Right, so I disagree with that here.
> 
> > @@ -5909,8 +5909,8 @@ void __init sched_init_smp(void)
> >  	mutex_unlock(&sched_domains_mutex);
> >  
> >  	/* Move init over to a non-isolated CPU */
> > -	if (set_cpus_allowed_ptr(current, non_isolated_cpus) < 0)
> > -		BUG();
> > +	BUG_ON(set_cpus_allowed_ptr(current, non_isolated_cpus) < 0);
> > +
> >  	sched_init_granularity();
> >  	free_cpumask_var(non_isolated_cpus);
> 
> If the condition were without side effects, that pattern would hold, but
> here the function call set_cpus_allowed_ptr() is very much not a pure
> function, so wrapping it in a BUG_ON() just fels wrong.

Got it - just looked throug core.c and there it seems only side-effect
free test-functions are wrapped in BUG_ON() so this change is inconsistent.
Other subsystems seem not to follow that logic - might be worth a note
somewhere below Documentation/.

thx!
hofrat

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ