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: <20210317200529.GB3830960@gmail.com>
Date:   Wed, 17 Mar 2021 21:05:29 +0100
From:   Ingo Molnar <mingo@...nel.org>
To:     Arnd Bergmann <arnd@...nel.org>
Cc:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] sched: replace if (cond) BUG() with BUG_ON()


* Arnd Bergmann <arnd@...nel.org> wrote:

> On Wed, Mar 17, 2021 at 9:45 AM Ingo Molnar <mingo@...nel.org> wrote:
> > * Ingo Molnar <mingo@...nel.org> wrote:
> > > * Jiapeng Chong <jiapeng.chong@...ux.alibaba.com> wrote:
> > >
> > > > Fix the following coccicheck warnings:
> > > >
> > > > ./kernel/sched/core.c:8039:2-5: WARNING: Use BUG_ON instead of if
> > > > condition followed by BUG.
> > > >
> > > > Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> > > > Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> > > > ---
> > > >  kernel/sched/core.c | 3 +--
> > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > >
> > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > > > index 9819121..7392bc0 100644
> > > > --- a/kernel/sched/core.c
> > > > +++ b/kernel/sched/core.c
> > > > @@ -8035,8 +8035,7 @@ 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, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
> > > > -           BUG();
> > > > +   BUG(set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0);
> > >
> > > The patch doesn't quite do what the title & changelog claims...
> >
> > More importantly, we use this pattern when we don't want !CONFIG_BUG
> > to remove the 'condition'.
> >
> > I.e. the "side effect" here is important scheduler logic. It must
> > never be optimized out.
> 
> This behavior for !CONFIG_BUG has changed a while ago, it is now safe
> to rely on the side-effect of the BUG_ON() condition regardless of
> CONFIG_BUG. When that option is disabled, running into the condition
> just ends up in a "do {} while (1)" loop.

Dunno, I still think it's not a particularly clean pattern to 'hide' 
significant side effects within a BUG_ON().

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ