[PATCH v3 0/3] Drivers: hv: vmbus: Fix a race condition in "_show" functions

From: Kimberly Brown
Date: Thu Mar 14 2019 - 16:04:59 EST


This patchset fixes a race condition in the "_show" functions that
access the channel ring buffers.

Changes in v3:
Patch 1: Drivers: hv: vmbus: Refactor chan->state if statement
- Added the âreviewed-byâ line from v2.

Patch 2: Drivers: hv: vmbus: Set ring_info field to 0 and remove memset
- This patch is new. This change allows the new mutex locks in patch 3
to be initialized when the channel is initialized.

Patch 3: Drivers: hv: vmbus: Fix race condition with new
ring_buffer_info mutex
- Added two ring buffer info mutex locks instead of the single channel
mutex lock that was proposed in v2.
- Changed the mutex acquire/release calls as needed for the new ring
buffer info mutex locks.
- Updated the commit message.


Changes in v2:
- In v1, I proposed using âvmbus_connection.channel_mutexâ in the
â_showâ functions to prevent the race condition. However, using this
mutex could result in a deadlock, so a new approach is proposed in
this patchset.
- Patch 1 is new and consists of refactoring an if statement.
- Patch 2 introduces a new mutex lock in the âvmbus_channelâ struct,
which is used to eliminate the race condition.

Kimberly Brown (3):
Drivers: hv: vmbus: Refactor chan->state if statement
Drivers: hv: vmbus: Set ring_info field to 0 and remove memset
Drivers: hv: vmbus: Fix race condition with new ring_buffer_info mutex

drivers/hv/channel_mgmt.c | 2 +
drivers/hv/hyperv_vmbus.h | 1 +
drivers/hv/ring_buffer.c | 22 ++++++++--
drivers/hv/vmbus_drv.c | 89 +++++++++++++++++++++++++++------------
include/linux/hyperv.h | 7 ++-
5 files changed, 88 insertions(+), 33 deletions(-)

--
2.17.1