Drivers: hv: vmbus: fix the race when querying & updating the percpu list
authorDexuan Cui <decui@microsoft.com>
Fri, 10 Jun 2016 01:47:24 +0000 (18:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2016 11:05:41 +0000 (13:05 +0200)
commit638fea33aee858cc665297a76f0039e95a28ce0c
treeb7d64f0d5feea234364b488021b729c1ef3434c0
parente0fa3e5e7df61eb2c339c9f0067c202c0cdeec2c
Drivers: hv: vmbus: fix the race when querying & updating the percpu list

There is a rare race when we remove an entry from the global list
hv_context.percpu_list[cpu] in hv_process_channel_removal() ->
percpu_channel_deq() -> list_del(): at this time, if vmbus_on_event() ->
process_chn_event() -> pcpu_relid2channel() is trying to query the list,
we can get the kernel fault.

Similarly, we also have the issue in the code path: vmbus_process_offer() ->
percpu_channel_enq().

We can resolve the issue by disabling the tasklet when updating the list.

The patch also moves vmbus_release_relid() to a later place where
the channel has been removed from the per-cpu and the global lists.

Reported-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/channel.c
drivers/hv/channel_mgmt.c
include/linux/hyperv.h