]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 13 Aug 2021 07:28:43 +0000 (09:28 +0200)
commit91d2af5343cee60ac3e41e883e68d1a5c299f918
tree3c15afda0537ecd00813f14b0aab4abc319a1fcd
parent02ce15808cf6dea237ad964bd8b9921e723aef3b
udp: fix race between close() and udp_abort()

BugLink: https://bugs.launchpad.net/bugs/1936688
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/ipv4/udp.c
net/ipv6/udp.c