Skip to contentSkip to conversation

tipc: fix shift wrapping bug in map_get()

PATCH Applied Dan Carpenter 2 participants 2 messages Aug 31, 2022 – Sep 2, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: fix shift wrapping bug in map_get()

There is a shift wrapping bug in this code so anything thing above 31 will return false.

Fixes 35c55c9877f8 ("tipc: add neighbor monitoring framework")

---
I have no idea why I didn't fix this back in 2016 when I fixed map_set().

 net/tipc/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/monitor.c +1 -1
index 2f4d23238a7e..9618e4429f0f 100644
@@ -160,7 +160,7 @@ static void map_set(u64 *up_map, int i, unsigned int v)
 
 static int map_get(u64 up_map, int i)
 {
-	return (up_map & (1 << i)) >> i;
+	return (up_map & (1ULL << i)) >> i;
 }
 
 static struct tipc_peer *peer_prev(struct tipc_peer *peer)
Signature · 1 line
2.35.1
#1 lore raw
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Wed, 31 Aug 2022 17:47:56 +0300 you wrote:

There is a shift wrapping bug in this code so anything thing above 31 will return false.

Fixes 35c55c9877f8 ("tipc: add neighbor monitoring framework")

---
I have no idea why I didn't fix this back in 2016 when I fixed map_set().

[...]

Here is the summary with links:
- [net] tipc: fix shift wrapping bug in map_get()

    https://git.kernel.org/netdev/net/c/e2b224abd9bf

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html