From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933377AbcLMPAL (ORCPT ); Tue, 13 Dec 2016 10:00:11 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44536 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932414AbcLMPAJ (ORCPT ); Tue, 13 Dec 2016 10:00:09 -0500 Date: Tue, 13 Dec 2016 07:00:03 -0800 From: "Paul E. McKenney" To: Colin Ian King Cc: Boqun Feng , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error Reply-To: paulmck@linux.vnet.ibm.com References: <20161213105646.9598-1-colin.king@canonical.com> <20161213112148.GE9728@tardis.cn.ibm.com> <3607072d-2418-df43-fd9a-2708a95f97da@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3607072d-2418-df43-fd9a-2708a95f97da@canonical.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121315-8235-0000-0000-00000A2CEE1C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006242; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000196; SDB=6.00793280; UDB=6.00384586; IPR=6.00571082; BA=6.00004963; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013618; XFM=3.00000011; UTC=2016-12-13 15:00:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121315-8236-0000-0000-0000379D73B7 Message-Id: <20161213150003.GZ3924@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-13_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612130242 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 13, 2016 at 11:33:19AM +0000, Colin Ian King wrote: > On 13/12/16 11:21, Boqun Feng wrote: > > On Tue, Dec 13, 2016 at 10:56:46AM +0000, Colin King wrote: > >> From: Colin Ian King > >> > >> 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. > >> > > > > Right, you are, and the tool is ;-) > > > > If @bit is greater than 32, we even got an undefined behavior in C ;-( > > This is my careless mistake, thank you for finding it out and fix it! > > > >> 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 > > > > I think Paul only queued that for running tests and I have almost > > finished a v2. I will fold your fix in my patch and add your SoB along > > with mine, does that work for you? > > Sure, that's good with me. And I have popped that series off of my queue. Thanx, Paul > > TBH, this situation is kinda new to me, so if anyone has any suggestion, > > please let me know ;-) > > > > Regards, > > Boqun > > > >> --- > >> 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; > >> > >> if (mask != 0) { > >> /* Idle/offline CPUs, report (releases rnp->lock. */ > >> -- > >> 2.10.2 > >> > >