]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
udp: fix race between close() and udp_abort()
authorPaolo Abeni <pabeni@redhat.com>
Wed, 9 Jun 2021 09:49:01 +0000 (11:49 +0200)
committerSasha Levin <sashal@kernel.org>
Wed, 30 Jun 2021 12:48:16 +0000 (08:48 -0400)
commit2f73448041bd0682d4b552cfd314ace66107f1ad
treebd2d5ba49db2d5a1b8bf50be63dd5ad6a5f42bcb
parent06b7cb0194bd1ede0dd27f3a946e7c0279fba44a
udp: fix race between close() and udp_abort()

[ Upstream commit a8b897c7bcd47f4147d066e22cc01d1026d7640e ]

Kaustubh reported and diagnosed a panic in udp_lib_lookup().
The root cause is udp_abort() racing with close(). Both
racing functions acquire the socket lock, but udp{v6}_destroy_sock()
release it before performing destructive actions.

We can't easily extend the socket lock scope to avoid the race,
instead use the SOCK_DEAD flag to prevent udp_abort from doing
any action when the critical race happens.

Diagnosed-and-tested-by: Kaustubh Pandey <kapandey@codeaurora.org>
Fixes: 5d77dca82839 ("net: diag: support SOCK_DESTROY for UDP sockets")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/udp.c
net/ipv6/udp.c