linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
@ 2018-12-13 16:35 Dexuan Cui
  2018-12-13 19:59 ` Sasha Levin
  2018-12-17 17:15 ` Stephen Hemminger
  0 siblings, 2 replies; 8+ messages in thread
From: Dexuan Cui @ 2018-12-13 16:35 UTC (permalink / raw)
  To: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org'
  Cc: Sasha Levin, 'apw@canonical.com',
	vkuznets, 'olaf@aepfle.de', 'jasowang@redhat.com',
	Michael Kelley


Before 98f4c651762c, we returned zeros for unopened channels.
With 98f4c651762c, we started to return random on-stack values.

We'd better return -EINVAL instead.

Fixes: 98f4c651762c ("hv: move ringbuffer bus attributes to dev_groups")
Cc: stable@vger.kernel.org
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 drivers/hv/vmbus_drv.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 283d184..d0ff656 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -316,6 +316,8 @@ static ssize_t out_intr_mask_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
 	return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
 }
@@ -329,6 +331,8 @@ static ssize_t out_read_index_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
 	return sprintf(buf, "%d\n", outbound.current_read_index);
 }
@@ -343,6 +347,8 @@ static ssize_t out_write_index_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
 	return sprintf(buf, "%d\n", outbound.current_write_index);
 }
@@ -357,6 +363,8 @@ static ssize_t out_read_bytes_avail_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
 	return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
 }
@@ -371,6 +379,8 @@ static ssize_t out_write_bytes_avail_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
 	return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
 }
@@ -384,6 +394,8 @@ static ssize_t in_intr_mask_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
 	return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
 }
@@ -397,6 +409,8 @@ static ssize_t in_read_index_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
 	return sprintf(buf, "%d\n", inbound.current_read_index);
 }
@@ -410,6 +424,8 @@ static ssize_t in_write_index_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
 	return sprintf(buf, "%d\n", inbound.current_write_index);
 }
@@ -424,6 +440,8 @@ static ssize_t in_read_bytes_avail_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
 	return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
 }
@@ -438,6 +456,8 @@ static ssize_t in_write_bytes_avail_show(struct device *dev,
 
 	if (!hv_dev->channel)
 		return -ENODEV;
+	if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
 	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
 	return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-13 16:35 [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels Dexuan Cui
@ 2018-12-13 19:59 ` Sasha Levin
  2018-12-17 17:15 ` Stephen Hemminger
  1 sibling, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2018-12-13 19:59 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org',
	Sasha Levin, 'apw@canonical.com',
	vkuznets, 'olaf@aepfle.de', 'jasowang@redhat.com',
	Michael Kelley

On Thu, Dec 13, 2018 at 04:35:43PM +0000, Dexuan Cui wrote:
>
>Before 98f4c651762c, we returned zeros for unopened channels.
>With 98f4c651762c, we started to return random on-stack values.
>
>We'd better return -EINVAL instead.
>
>Fixes: 98f4c651762c ("hv: move ringbuffer bus attributes to dev_groups")
>Cc: stable@vger.kernel.org
>Cc: K. Y. Srinivasan <kys@microsoft.com>
>Cc: Haiyang Zhang <haiyangz@microsoft.com>
>Cc: Stephen Hemminger <sthemmin@microsoft.com>
>Signed-off-by: Dexuan Cui <decui@microsoft.com>

Queued up, thank you.

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-13 16:35 [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels Dexuan Cui
  2018-12-13 19:59 ` Sasha Levin
@ 2018-12-17 17:15 ` Stephen Hemminger
  2018-12-17 18:00   ` Dexuan Cui
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-12-17 17:15 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org', 'olaf@aepfle.de',
	'jasowang@redhat.com',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	vkuznets

On Thu, 13 Dec 2018 16:35:43 +0000
Dexuan Cui <decui@microsoft.com> wrote:

> Before 98f4c651762c, we returned zeros for unopened channels.
> With 98f4c651762c, we started to return random on-stack values.
> 
> We'd better return -EINVAL instead.
> 
> Fixes: 98f4c651762c ("hv: move ringbuffer bus attributes to dev_groups")
> Cc: stable@vger.kernel.org
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>

The concept looks fine, but maybe it would be simpler to move it into
hv_ringbuffer_get_debuginfo and have it return an error code.

Since so much of the code is repeated, I would probably make a
macro which generates the code as well.

Something like this:

From c6bbdbcde933c85098f7b3e71650a8479d52810c Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <sthemmin@microsoft.com>
Date: Mon, 17 Dec 2018 09:13:24 -0800
Subject: [PATCH] hv: vmbus: check for ring in debug info

---
 drivers/hv/ring_buffer.c | 31 +++++++++---------
 drivers/hv/vmbus_drv.c   | 71 ++++++++++++++++++++++++++++++++++------
 include/linux/hyperv.h   |  5 +--
 3 files changed, 79 insertions(+), 28 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 64d0c85d5161..1f1a55e07733 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -164,26 +164,25 @@ hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi,
 }
 
 /* Get various debug metrics for the specified ring buffer. */
-void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
-				 struct hv_ring_buffer_debug_info *debug_info)
+int hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
+				struct hv_ring_buffer_debug_info *debug_info)
 {
 	u32 bytes_avail_towrite;
 	u32 bytes_avail_toread;
 
-	if (ring_info->ring_buffer) {
-		hv_get_ringbuffer_availbytes(ring_info,
-					&bytes_avail_toread,
-					&bytes_avail_towrite);
-
-		debug_info->bytes_avail_toread = bytes_avail_toread;
-		debug_info->bytes_avail_towrite = bytes_avail_towrite;
-		debug_info->current_read_index =
-			ring_info->ring_buffer->read_index;
-		debug_info->current_write_index =
-			ring_info->ring_buffer->write_index;
-		debug_info->current_interrupt_mask =
-			ring_info->ring_buffer->interrupt_mask;
-	}
+	if (!ring_info->ring_buffer)
+		return -EINVAL;
+
+	hv_get_ringbuffer_availbytes(ring_info,
+				     &bytes_avail_toread,
+				     &bytes_avail_towrite);
+	debug_info->bytes_avail_toread = bytes_avail_toread;
+	debug_info->bytes_avail_towrite = bytes_avail_towrite;
+	debug_info->current_read_index = ring_info->ring_buffer->read_index;
+	debug_info->current_write_index = ring_info->ring_buffer->write_index;
+	debug_info->current_interrupt_mask
+		= ring_info->ring_buffer->interrupt_mask;
+	return 0;
 }
 EXPORT_SYMBOL_GPL(hv_ringbuffer_get_debuginfo);
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 283d184280af..403fee01572c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -313,10 +313,16 @@ static ssize_t out_intr_mask_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info outbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
+					  &outbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
 }
 static DEVICE_ATTR_RO(out_intr_mask);
@@ -326,10 +332,15 @@ static ssize_t out_read_index_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info outbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
+					  &outbound);
+	if (ret < 0)
+		return ret;
 	return sprintf(buf, "%d\n", outbound.current_read_index);
 }
 static DEVICE_ATTR_RO(out_read_index);
@@ -340,10 +351,15 @@ static ssize_t out_write_index_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info outbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
+					  &outbound);
+	if (ret < 0)
+		return ret;
 	return sprintf(buf, "%d\n", outbound.current_write_index);
 }
 static DEVICE_ATTR_RO(out_write_index);
@@ -354,10 +370,15 @@ static ssize_t out_read_bytes_avail_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info outbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
+					  &outbound);
+	if (ret < 0)
+		return ret;
 	return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
 }
 static DEVICE_ATTR_RO(out_read_bytes_avail);
@@ -368,10 +389,15 @@ static ssize_t out_write_bytes_avail_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info outbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound,
+					  &outbound);
+	if (ret < 0)
+		return ret;
 	return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
 }
 static DEVICE_ATTR_RO(out_write_bytes_avail);
@@ -381,10 +407,15 @@ static ssize_t in_intr_mask_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info inbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
 }
 static DEVICE_ATTR_RO(in_intr_mask);
@@ -394,10 +425,15 @@ static ssize_t in_read_index_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info inbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", inbound.current_read_index);
 }
 static DEVICE_ATTR_RO(in_read_index);
@@ -407,10 +443,15 @@ static ssize_t in_write_index_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info inbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", inbound.current_write_index);
 }
 static DEVICE_ATTR_RO(in_write_index);
@@ -421,10 +462,15 @@ static ssize_t in_read_bytes_avail_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info inbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
 }
 static DEVICE_ATTR_RO(in_read_bytes_avail);
@@ -435,10 +481,15 @@ static ssize_t in_write_bytes_avail_show(struct device *dev,
 {
 	struct hv_device *hv_dev = device_to_hv_device(dev);
 	struct hv_ring_buffer_debug_info inbound;
+	int ret;
 
 	if (!hv_dev->channel)
 		return -ENODEV;
-	hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+
+	ret = hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
+	if (ret < 0)
+		return ret;
+
 	return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
 }
 static DEVICE_ATTR_RO(in_write_bytes_avail);
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 14131b6fae68..ed74888087f1 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1176,8 +1176,9 @@ struct hv_ring_buffer_debug_info {
 	u32 bytes_avail_towrite;
 };
 
-void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
-			    struct hv_ring_buffer_debug_info *debug_info);
+
+int hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info,
+				struct hv_ring_buffer_debug_info *debug_info);
 
 /* Vmbus interface */
 #define vmbus_driver_register(driver)	\
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-17 17:15 ` Stephen Hemminger
@ 2018-12-17 18:00   ` Dexuan Cui
  2018-12-17 18:17     ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Dexuan Cui @ 2018-12-17 18:00 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org', 'olaf@aepfle.de',
	'jasowang@redhat.com',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	vkuznets

> From: Stephen Hemminger <stephen@networkplumber.org>
> On Thu, 13 Dec 2018 16:35:43 +0000
> Dexuan Cui <decui@microsoft.com> wrote:
> 
> > Before 98f4c651762c, we returned zeros for unopened channels.
> > With 98f4c651762c, we started to return random on-stack values.
> >
> > We'd better return -EINVAL instead.
> 
> The concept looks fine, but maybe it would be simpler to move it into
> hv_ringbuffer_get_debuginfo and have it return an error code.
> 
> Since so much of the code is repeated, I would probably make a
> macro which generates the code as well.
> 
> Something like this:

Thanks, Stephen! Now the patch has been in char-misc's char-misc-linus
branch, so IMO we may as well leave it as is (considering the code here is
unlikely to be frqeuencly changed), and we have a smaller patch this way. :-)

But, yes, I agree with you that generally we should make a common
function to avoid duplicate code.

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-17 18:00   ` Dexuan Cui
@ 2018-12-17 18:17     ` Stephen Hemminger
  2018-12-17 18:31       ` Dexuan Cui
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-12-17 18:17 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org', 'olaf@aepfle.de',
	'jasowang@redhat.com',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	vkuznets

On Mon, 17 Dec 2018 18:00:29 +0000
Dexuan Cui <decui@microsoft.com> wrote:

> > From: Stephen Hemminger <stephen@networkplumber.org>
> > On Thu, 13 Dec 2018 16:35:43 +0000
> > Dexuan Cui <decui@microsoft.com> wrote:
> >   
> > > Before 98f4c651762c, we returned zeros for unopened channels.
> > > With 98f4c651762c, we started to return random on-stack values.
> > >
> > > We'd better return -EINVAL instead.  
> > 
> > The concept looks fine, but maybe it would be simpler to move it into
> > hv_ringbuffer_get_debuginfo and have it return an error code.
> > 
> > Since so much of the code is repeated, I would probably make a
> > macro which generates the code as well.
> > 
> > Something like this:  
> 
> Thanks, Stephen! Now the patch has been in char-misc's char-misc-linus
> branch, so IMO we may as well leave it as is (considering the code here is
> unlikely to be frqeuencly changed), and we have a smaller patch this way. :-)
> 
> But, yes, I agree with you that generally we should make a common
> function to avoid duplicate code.
> 
> Thanks,
> -- Dexuan

The old code was risky because it would silently return stack garbage.
Having an error check in get_debuginfo would eliminate that.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-17 18:17     ` Stephen Hemminger
@ 2018-12-17 18:31       ` Dexuan Cui
  2018-12-17 18:44         ` Dexuan Cui
  0 siblings, 1 reply; 8+ messages in thread
From: Dexuan Cui @ 2018-12-17 18:31 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: 'gregkh@linuxfoundation.org',
	KY Srinivasan, Haiyang Zhang,
	'linux-kernel@vger.kernel.org',
	'devel@linuxdriverproject.org', 'olaf@aepfle.de',
	'jasowang@redhat.com',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	vkuznets

> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, December 17, 2018 10:17 AM
> To: Dexuan Cui <decui@microsoft.com>
> 
> On Mon, 17 Dec 2018 18:00:29 +0000
> Dexuan Cui <decui@microsoft.com> wrote:
> 
> > > From: Stephen Hemminger <stephen@networkplumber.org>
> > > On Thu, 13 Dec 2018 16:35:43 +0000
> > > Dexuan Cui <decui@microsoft.com> wrote:
> > >
> > > > Before 98f4c651762c, we returned zeros for unopened channels.
> > > > With 98f4c651762c, we started to return random on-stack values.
> > > >
> > > > We'd better return -EINVAL instead.
> > >
> > > The concept looks fine, but maybe it would be simpler to move it into
> > > hv_ringbuffer_get_debuginfo and have it return an error code.
> > >
> > > Since so much of the code is repeated, I would probably make a
> > > macro which generates the code as well.
> > >
> > > Something like this:
> >
> > Thanks, Stephen! Now the patch has been in char-misc's char-misc-linus
> > branch, so IMO we may as well leave it as is (considering the code here is
> > unlikely to be frqeuencly changed), and we have a smaller patch this way. :-)
> >
> > But, yes, I agree with you that generally we should make a common
> > function to avoid duplicate code.
> >
> > Thanks,
> > -- Dexuan
> 
> The old code was risky because it would silently return stack garbage.
> Having an error check in get_debuginfo would eliminate that.

OK, then let me make another patch based on the latest char-misc-linus.

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-17 18:31       ` Dexuan Cui
@ 2018-12-17 18:44         ` Dexuan Cui
  2018-12-17 20:35           ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Dexuan Cui @ 2018-12-17 18:44 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: 'olaf@aepfle.de', 'gregkh@linuxfoundation.org',
	Haiyang Zhang, 'linux-kernel@vger.kernel.org',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	'devel@linuxdriverproject.org',
	vkuznets, 'jasowang@redhat.com'

> From: devel <driverdev-devel-bounces@linuxdriverproject.org> On Behalf Of
> Dexuan Cui
> Sent: Monday, December 17, 2018 10:31 AM
> > From: Stephen Hemminger <stephen@networkplumber.org>
> >
> > The old code was risky because it would silently return stack garbage.
> > Having an error check in get_debuginfo would eliminate that.
> 
> OK, then let me make another patch based on the latest char-misc-linus.
> 
> -- Dexuan

Hi Stephen, your patch can apply cleanly. Let me rebase your patch to
char-misc-linus, do a test, and then post it with your Signed-off-by and mine: 
I assume you're Ok with this. Please let me know in case it's not. :-)

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
  2018-12-17 18:44         ` Dexuan Cui
@ 2018-12-17 20:35           ` Stephen Hemminger
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2018-12-17 20:35 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: 'olaf@aepfle.de', 'gregkh@linuxfoundation.org',
	Haiyang Zhang, 'linux-kernel@vger.kernel.org',
	Michael Kelley, Sasha Levin, 'apw@canonical.com',
	'devel@linuxdriverproject.org',
	vkuznets, 'jasowang@redhat.com'

On Mon, 17 Dec 2018 18:44:12 +0000
Dexuan Cui <decui@microsoft.com> wrote:

> > From: devel <driverdev-devel-bounces@linuxdriverproject.org> On Behalf Of
> > Dexuan Cui
> > Sent: Monday, December 17, 2018 10:31 AM  
> > > From: Stephen Hemminger <stephen@networkplumber.org>
> > >
> > > The old code was risky because it would silently return stack garbage.
> > > Having an error check in get_debuginfo would eliminate that.  
> > 
> > OK, then let me make another patch based on the latest char-misc-linus.
> > 
> > -- Dexuan  
> 
> Hi Stephen, your patch can apply cleanly. Let me rebase your patch to
> char-misc-linus, do a test, and then post it with your Signed-off-by and mine: 
> I assume you're Ok with this. Please let me know in case it's not. :-)
> 
> Thanks,
> -- Dexuan

Sure.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-12-17 20:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 16:35 [PATCH] Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels Dexuan Cui
2018-12-13 19:59 ` Sasha Levin
2018-12-17 17:15 ` Stephen Hemminger
2018-12-17 18:00   ` Dexuan Cui
2018-12-17 18:17     ` Stephen Hemminger
2018-12-17 18:31       ` Dexuan Cui
2018-12-17 18:44         ` Dexuan Cui
2018-12-17 20:35           ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).