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-next>] [day] [month] [year] [list]
Message-Id: <20161213183647.GD3924@linux.vnet.ibm.com>
Date:   Tue, 13 Dec 2016 10:36:47 -0800
From:   "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:     Boqun Feng <boqun.feng@...il.com>
Cc:     Mark Rutland <mark.rutland@....com>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Josh Triplett <josh@...htriplett.org>,
        Colin King <colin.king@...onical.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension
 error

On Wed, Dec 14, 2016 at 02:09:27AM +0800, Boqun Feng wrote:
> 2016年12月14日 上午1:17,"Mark Rutland" <mark.rutland@....com>写道:
> >
> > Hi,
> >
> > On Tue, Dec 13, 2016 at 10:56:46AM +0000, Colin King wrote:
> > > From: Colin Ian King <colin.king@...onical.com>
> > >
> > > mask and bit are unsigned longs, so if bit is 31 we end up sign
> > > extending the 1 and mask ends up as 0xffffffff80000000. Fix this
> > > by explicitly adding integer suffix UL ensure 1 is a unsigned long
> > > rather than an signed int.
> > >
> > > Issue found with static analysis with CoverityScan, CID 1388564
> > >
> > > Fixes: 8965c3ce4718754db ("rcu: Use
> leaf_node_for_each_mask_possible_cpu() in force_qs_rnp()")
> > > Signed-off-by: Colin Ian King <colin.king@...onical.com>
> > > ---
> > >  kernel/rcu/tree.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > > index 10162ac..6ecedd8 100644
> > > --- a/kernel/rcu/tree.c
> > > +++ b/kernel/rcu/tree.c
> > > @@ -3051,7 +3051,7 @@ static void force_qs_rnp(struct rcu_state *rsp,
> > >
> > >               leaf_node_for_each_mask_possible_cpu(rnp, rnp->qsmask,
> bit, cpu)
> > >                       if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj))
> > > -                             mask |= 1 << bit;
> > > +                             mask |= 1UL << bit;
> >
> > So as to match the rest of the code altered in commit bc75e99983df1efd
> > ("rcu: Correctly handle sparse possible cpus"), and regardless of
> > naming, I think it'd be nicer to use leaf_node_cpu_bit(), e.g.
> >
> >         leaf_node_for_each_mask_possible_cpu(rnp, rnp->qsmask, bit, cpu)
> >                 if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj))
> >                         mask |= leaf_node_cpu_bit(rnp, cpu);
> >
> > IMO, it would be nice to hide the iterator bit somehow, to match
> > for_each_leaf_node_possible_cpu(), which this largely looks similar to
> > otherwise.
> 
> Good point. ;-)
> 
> We can
> 
> #define for_each_leaf_node_cpu(rnp, mask, cpu) \
>         for((cpu) = (rnp)->grplo + find _first_bit(mask, MASK_BITS(mask)); \
>             (cpu) >= (rnp)->grplo && (cpu) <= (rnp)->grphi; \
>             (cpu) = (rnp)->grplo + find _next_bit(mask, ...,
> leaf_node_cpu_bit(rnp, cpu) + 1))) \
>                 if (!cpu_possible(cpu)) \
>                         continue; \
>                 else

What is the purpose of the cpu_possible() check?

							Thanx, Paul

> Typing from my cellphone, plz ignore the bad formatting ;-)
> 
> Regards,
> Boqun
> 
> > Thanks,
> > Mark.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ