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: <429249323d5f41ebbfa4f9e0294b2ddb@AcuMS.aculab.com>
Date:   Tue, 5 Sep 2023 09:31:48 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Mathieu Desnoyers' <mathieu.desnoyers@...icios.com>,
        Denis Arefev <arefev@...mel.ru>,
        Lai Jiangshan <jiangshanlai@...il.com>
CC:     "Paul E. McKenney" <paulmck@...nel.org>,
        Josh Triplett <josh@...htriplett.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        "rcu@...r.kernel.org" <rcu@...r.kernel.org>,
        "lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "trufanov@...mel.ru" <trufanov@...mel.ru>,
        "vfh@...mel.ru" <vfh@...mel.ru>
Subject: RE: [PATCH v2] The value may overflow

From: Mathieu Desnoyers
> Sent: 04 September 2023 11:24
> 
> On 9/4/23 05:42, Denis Arefev wrote:
> > The value of an arithmetic expression 1 << (cpu - sdp->mynode->grplo)
> > is subject to overflow due to a failure to cast operands to a larger
> > data type before performing arithmetic
> 
> The patch title should identify more precisely its context, e.g.:
> 
> "srcu: Fix srcu_struct node grpmask overflow on 64-bit systems"
> 
> Also, as I stated in my reply to the previous version, the patch commit
> message should describe the impact of the bug it fixes.

And is the analysis complete?
Is 1UL right for 32bit archs??
Is 64 bits even enough??

	David

> 
> Thanks,
> 
> Mathieu
> 
> 
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Signed-off-by: Denis Arefev <arefev@...mel.ru>
> > ---
> > v2: Added fixes to the srcu_schedule_cbs_snp function as suggested by
> > Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
> >   kernel/rcu/srcutree.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index 20d7a238d675..6c18e6005ae1 100644
> > --- a/kernel/rcu/srcutree.c
> > +++ b/kernel/rcu/srcutree.c
> > @@ -223,7 +223,7 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags)
> >   				snp->grplo = cpu;
> >   			snp->grphi = cpu;
> >   		}
> > -		sdp->grpmask = 1 << (cpu - sdp->mynode->grplo);
> > +		sdp->grpmask = 1UL << (cpu - sdp->mynode->grplo);
> >   	}
> >   	smp_store_release(&ssp->srcu_sup->srcu_size_state, SRCU_SIZE_WAIT_BARRIER);
> >   	return true;
> > @@ -833,7 +833,7 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *ssp, struct srcu_node *snp
> >   	int cpu;
> >
> >   	for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) {
> > -		if (!(mask & (1 << (cpu - snp->grplo))))
> > +		if (!(mask & (1UL << (cpu - snp->grplo))))
> >   			continue;
> >   		srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay);
> >   	}
> 
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> https://www.efficios.com

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ