Message ID | 20211105214214.2259841-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 8ac9dfd58b138f7e82098a4e0a0d46858b12215b |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] llc: fix out-of-bound array index in llc_sk_dev_hash() | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Fri, 5 Nov 2021 14:42:14 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Both ifindex and LLC_SK_DEV_HASH_ENTRIES are signed. > > This means that (ifindex % LLC_SK_DEV_HASH_ENTRIES) is negative > if @ifindex is negative. > > [...] Here is the summary with links: - [net] llc: fix out-of-bound array index in llc_sk_dev_hash() https://git.kernel.org/netdev/net/c/8ac9dfd58b13 You are awesome, thank you!
diff --git a/include/net/llc.h b/include/net/llc.h index fd1f9a3fd8dda463cc24d95e0d3a528e505927b4..e250dca03963bf14750d16ebf1cb6d976b7206d3 100644 --- a/include/net/llc.h +++ b/include/net/llc.h @@ -72,7 +72,9 @@ struct llc_sap { static inline struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) { - return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; + u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS); + + return &sap->sk_dev_hash[bucket]; } static inline