diff options
author | Dexuan Cui <decui@microsoft.com> | 2019-07-31 03:25:45 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-08-03 02:26:27 +0200 |
commit | 685703b497bacea8765bb409d6b73455b73c540e (patch) | |
tree | 0b1318ea44c69b0e5e612f4e91c37d2bf9189780 /drivers/atm/iphase.c | |
parent | net: usb: pegasus: fix improper read if get_registers() fail (diff) | |
download | linux-685703b497bacea8765bb409d6b73455b73c540e.tar.xz linux-685703b497bacea8765bb409d6b73455b73c540e.zip |
hv_sock: Fix hang when a connection is closed
There is a race condition for an established connection that is being closed
by the guest: the refcnt is 4 at the end of hvs_release() (Note: here the
'remove_sock' is false):
1 for the initial value;
1 for the sk being in the bound list;
1 for the sk being in the connected list;
1 for the delayed close_work.
After hvs_release() finishes, __vsock_release() -> sock_put(sk) *may*
decrease the refcnt to 3.
Concurrently, hvs_close_connection() runs in another thread:
calls vsock_remove_sock() to decrease the refcnt by 2;
call sock_put() to decrease the refcnt to 0, and free the sk;
next, the "release_sock(sk)" may hang due to use-after-free.
In the above, after hvs_release() finishes, if hvs_close_connection() runs
faster than "__vsock_release() -> sock_put(sk)", then there is not any issue,
because at the beginning of hvs_close_connection(), the refcnt is still 4.
The issue can be resolved if an extra reference is taken when the
connection is established.
Fixes: a9eeb998c28d ("hv_sock: Add support for delayed close")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Sunil Muthuswamy <sunilmut@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/iphase.c')
0 files changed, 0 insertions, 0 deletions