Martin KaFai Lau 5456262d2b net: Fix incorrect address comparison when searching for a bind2 bucket
The v6_rcv_saddr and rcv_saddr are inside a union in the
'struct inet_bind2_bucket'.  When searching a bucket by following the
bhash2 hashtable chain, eg. inet_bind2_bucket_match, it is only using
the sk->sk_family and there is no way to check if the inet_bind2_bucket
has a v6 or v4 address in the union.  This leads to an uninit-value
KMSAN report in [0] and also potentially incorrect matches.

This patch fixes it by adding a family member to the inet_bind2_bucket
and then tests 'sk->sk_family != tb->family' before matching
the sk's address to the tb's address.

Cc: Joanne Koong <joannelkoong@gmail.com>
Fixes: 28044fc1d495 ("net: Add a bhash2 table hashed by port and address")
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Link: https://lore.kernel.org/r/20220927002544.3381205-1-kafai@fb.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-28 18:52:17 -07:00
..
2022-07-12 12:58:53 +02:00
2022-09-20 10:21:49 -07:00
2021-05-17 15:29:35 -07:00
2022-09-28 18:51:25 -07:00
2021-10-13 09:41:37 -07:00
2021-06-30 15:51:09 -07:00
2021-10-13 09:41:37 -07:00
2022-04-12 14:56:33 -07:00
2021-05-17 15:29:35 -07:00
2022-06-21 11:38:29 +02:00
2022-06-24 22:48:33 -07:00
2022-09-20 10:21:49 -07:00
2022-09-28 18:52:03 -07:00
2021-05-17 15:29:35 -07:00
2022-09-26 11:00:19 -07:00