ping: Fix potentail NULL deref for /proc/net/icmp.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 3 Apr 2023 19:49:59 +0000 (12:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Apr 2023 14:55:24 +0000 (16:55 +0200)
commit5a08a32e624908890aa0a2eb442bb6a7669891a8
treecc2b3f95551f125f77aa35f9044b66e9b1479589
parentb34056bedf04d08ef24f713a7f93bad1274a838d
ping: Fix potentail NULL deref for /proc/net/icmp.

[ Upstream commit ab5fb73ffa01072b4d8031cc05801fa1cb653bee ]

After commit dbca1596bbb0 ("ping: convert to RCU lookups, get rid
of rwlock"), we use RCU for ping sockets, but we should use spinlock
for /proc/net/icmp to avoid a potential NULL deref mentioned in
the previous patch.

Let's go back to using spinlock there.

Note we can convert ping sockets to use hlist instead of hlist_nulls
because we do not use SLAB_TYPESAFE_BY_RCU for ping sockets.

Fixes: dbca1596bbb0 ("ping: convert to RCU lookups, get rid of rwlock")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/ping.c