]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xen-netfront: fix potential deadlock in xennet_remove()
authorAndrea Righi <andrea.righi@canonical.com>
Fri, 24 Jul 2020 08:59:10 +0000 (10:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 07:58:50 +0000 (09:58 +0200)
commitcb748f1cf7d365c849f170073196698ec69df7ea
tree9f5a149963c2f5da9d1cc9089cb14356a8d554fd
parentef47367fd208db3ff7daa74bd32227df94b58177
xen-netfront: fix potential deadlock in xennet_remove()

[ Upstream commit c2c633106453611be07821f53dff9e93a9d1c3f0 ]

There's a potential race in xennet_remove(); this is what the driver is
doing upon unregistering a network device:

  1. state = read bus state
  2. if state is not "Closed":
  3.    request to set state to "Closing"
  4.    wait for state to be set to "Closing"
  5.    request to set state to "Closed"
  6.    wait for state to be set to "Closed"

If the state changes to "Closed" immediately after step 1 we are stuck
forever in step 4, because the state will never go back from "Closed" to
"Closing".

Make sure to check also for state == "Closed" in step 4 to prevent the
deadlock.

Also add a 5 sec timeout any time we wait for the bus state to change,
to avoid getting stuck forever in wait_event().

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/xen-netfront.c