All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error
@ 2016-12-13 10:56 Colin King
  2016-12-13 11:21 ` Boqun Feng
  2016-12-13 17:16 ` Mark Rutland
  0 siblings, 2 replies; 16+ messages in thread
From: Colin King @ 2016-12-13 10:56 UTC (permalink / raw)
  To: Boqun Feng, Paul E . McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan
  Cc: linux-kernel

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;
 
 		if (mask != 0) {
 			/* Idle/offline CPUs, report (releases rnp->lock. */
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-12-14 14:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13 10:56 [PATCH] rcu: shift by 1UL rather than 1 to fix sign extension error Colin King
2016-12-13 11:21 ` Boqun Feng
2016-12-13 11:33   ` Colin Ian King
2016-12-13 15:00     ` Paul E. McKenney
2016-12-14 14:42     ` Boqun Feng
2016-12-14 14:54       ` Colin Ian King
2016-12-13 12:25   ` Boqun Feng
2016-12-13 15:05     ` Paul E. McKenney
2016-12-13 17:16 ` Mark Rutland
     [not found]   ` <CAL0jBu8ackxPrOALVnx96FSyD_-sZAAMySikqYw2uf8LEezr9g@mail.gmail.com>
2016-12-13 18:36     ` Paul E. McKenney
2016-12-14  0:47       ` Boqun Feng
2016-12-14  1:40         ` Boqun Feng
2016-12-14  4:13           ` Paul E. McKenney
2016-12-14 10:55           ` Mark Rutland
2016-12-14 13:03             ` Boqun Feng
2016-12-14  1:06     ` Boqun Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.