]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 19 Oct 2016 13:53:01 +0000 (15:53 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Oct 2016 15:27:31 +0000 (11:27 -0400)
commite8f0a89cd7591c5d4eb7c77833af865b4db356b7
tree3dc3e1a0ff45a0b2182ead62097b19799a4d8305
parent9e58c5dc4be31f8cf3ff62d96f91c97af6f9d58e
hv_netvsc: fix a race between netvsc_send() and netvsc_init_buf()

Fix in commit 880988348270 ("hv_netvsc: set nvdev link after populating
chn_table") turns out to be incomplete. A crash in
netvsc_get_next_send_section() is observed on mtu change when the device
is under load. The race I identified is: if we get to netvsc_send() after
we set net_device_ctx->nvdev link in netvsc_device_add() but before we
finish netvsc_connect_vsp()->netvsc_init_buf() send_section_map is not
allocated and we crash. Unfortunately we can't set net_device_ctx->nvdev
link after the netvsc_init_buf() call as during the negotiation we need
to receive packets and on the receive path we check for it. It would
probably be possible to split nvdev into a pair of nvdev_in and nvdev_out
links and check them accordingly in get_outbound_net_device()/
get_inbound_net_device() but this looks like an overkill.

Check that send_section_map is allocated in netvsc_send().

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc.c