From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753598AbcLMK5Y (ORCPT ); Tue, 13 Dec 2016 05:57:24 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:43813 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbcLMK5X (ORCPT ); Tue, 13 Dec 2016 05:57:23 -0500 From: Colin King To: Boqun Feng , "Paul E . McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan Cc: linux-kernel@vger.kernel.org Subject: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error Date: Tue, 13 Dec 2016 10:56:46 +0000 Message-Id: <20161213105646.9598-1-colin.king@canonical.com> X-Mailer: git-send-email 2.10.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 --- 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