[<prev] [next>] [day] [month] [year] [list]
Date: Tue, 10 Oct 2017 04:49:04 +0000
From: Dexuan Cui <decui@...rosoft.com>
To: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"Stephen Hemminger" <sthemmin@...rosoft.com>,
KY Srinivasan <kys@...rosoft.com>,
"driverdev-devel@...uxdriverproject.org"
<driverdev-devel@...uxdriverproject.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"'Cathy Avery'" <cavery@...hat.com>,
Marcelo Henrique Cerri <marcelo.cerri@...onical.com>,
"olaf@...fle.de" <olaf@...fle.de>,
"'Rolf Neugebauer'" <rolf.neugebauer@...ker.com>,
"apw@...onical.com" <apw@...onical.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Haiyang Zhang <haiyangz@...rosoft.com>
Subject: [PATCH] vmbus: hvsock: add proper sync for
vmbus_hvsock_device_unregister()
Without the patch, vmbus_hvsock_device_unregister() can destroy the device
prematurely when close() is called, and can cause NULl dereferencing or
potential data loss (the last portion of the data stream may be dropped
prematurely).
Signed-off-by: Dexuan Cui <decui@...rosoft.com>
Cc: K. Y. Srinivasan <kys@...rosoft.com>
Cc: Haiyang Zhang <haiyangz@...rosoft.com>
Cc: Stephen Hemminger <sthemmin@...rosoft.com>
---
The patch is rebased on today's char-misc tree's char-misc-linus branch.
Please consider it for v4.14.
drivers/hv/channel_mgmt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 018d2e0..379b0df 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -937,7 +937,10 @@ void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
{
BUG_ON(!is_hvsock_channel(channel));
- channel->rescind = true;
+ /* We always get a rescind msg when a connection is closed. */
+ while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind))
+ msleep(1);
+
vmbus_device_unregister(channel->device_obj);
}
EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
--
2.7.4
Powered by blists - more mailing lists