Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1541967

Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Colin Ian King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error
Date Wed, 14 Dec 2016 16:00:01 +0100
Message-ID <sOjcd-7GR-13@gated-at.bofh.it> (permalink)
References <sNSYq-aO-31@gated-at.bofh.it> <sNTrr-zs-3@gated-at.bofh.it> <sNTB7-CJ-9@gated-at.bofh.it> <sOj2y-7DE-11@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0
MIME-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UqvhrFlf9wUM6W0dIIQtJ35mU0xWKK48O"
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 131
Organization linux.* mail to news gateway
X-Original-Cc "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>, Josh Triplett <josh@joshtriplett.org>, Steven Rostedt <rostedt@goodmis.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Lai Jiangshan <jiangshanlai@gmail.com>, linux-kernel@vger.kernel.org
X-Original-Date Wed, 14 Dec 2016 14:54:34 +0000
X-Original-Message-ID <21d2e114-26a9-2eff-893b-9ed2295248ce@canonical.com>
X-Original-References <20161213105646.9598-1-colin.king@canonical.com> <20161213112148.GE9728@tardis.cn.ibm.com> <3607072d-2418-df43-fd9a-2708a95f97da@canonical.com> <20161214144244.GL9728@tardis.cn.ibm.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1541967

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 14/12/16 14:42, Boqun Feng wrote:
> 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 <colin.king@canonical.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.
>>>>
>>>
>>> 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 <colin.king@canonical.com>
>>>
>>> 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.
>>
> 
> Colin, as I'm going to take Mark's suggestion and use
> leaf_node_cpu_bit() instead. So I'm going to drop your SoB but keep a
> commit message saying you spotted the problem at the first place. Hope
> that works with you ;-)

Yep, that's totally fine. Thanks.

Colin

> 
> Regards,
> Boqun
> 
>>>
>>> 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
>>>>
>>
>>
> 
> 
> 


Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error Colin King <colin.king@canonical.com> - 2016-12-13 12:00 +0100
  Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-13 12:30 +0100
    Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Colin Ian King <colin.king@canonical.com> - 2016-12-13 12:40 +0100
      Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-13 16:10 +0100
      Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-14 15:50 +0100
        Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Colin Ian King <colin.king@canonical.com> - 2016-12-14 16:00 +0100
    Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-13 13:30 +0100
      Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-13 16:10 +0100
  Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Mark Rutland <mark.rutland@arm.com> - 2016-12-13 18:20 +0100
    Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-13 19:40 +0100
      Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-14 01:50 +0100
        Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-14 02:50 +0100
          Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-14 05:20 +0100
          Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Mark Rutland <mark.rutland@arm.com> - 2016-12-14 12:00 +0100
            Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-14 14:10 +0100
    Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension  error Boqun Feng <boqun.feng@gmail.com> - 2016-12-14 02:10 +0100

csiph-web