Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1541274
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error |
| Date | 2016-12-13 18:20 +0100 |
| Message-ID | <sNYU9-3UP-7@gated-at.bofh.it> (permalink) |
| References | <sNSYq-aO-31@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi,
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.
>
> 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>
> ---
> 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.
Thanks,
Mark.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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