Skip to contentSkip to conversation

vmbus: don't return values for uninitalized channels

PATCH In review [email protected] 2 participants 2 messages Aug 20, 2018 – Aug 30, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmbus: don't return values for uninitalized channels

From: Stephen Hemminger <[email protected]>

For unsupported device types, the vmbus channel ringbuffer is never initialized, and therefore reading the sysfs files will return garbage or cause a kernel OOPS.

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")
---
 drivers/hv/vmbus_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/hv/vmbus_drv.c +3 -0
index e6d8fdac6d8b..4bbc420d1213 100644
@@ -1368,6 +1368,9 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj,
 	if (!attribute->show)
 		return -EIO;
 
+	if (chan->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
+
 	return attribute->show(chan, buf);
 }
 
Signature · 1 line
2.18.0
#1 lore raw
Quoted 11 lines · [email protected] writes:

From: Stephen Hemminger <[email protected]>

For unsupported device types, the vmbus channel ringbuffer is never initialized, and therefore reading the sysfs files will return garbage or cause a kernel OOPS.

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

As this is also marked for stable, any chance we can get it in 4.19? Or at least in char-misc-next?

Quoted 9 lines
---
 drivers/hv/vmbus_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/hv/vmbus_drv.c +0 -0
index e6d8fdac6d8b..4bbc420d1213 100644

drivers/hv/vmbus_drv.c static ssize_t vmbus_chan_attr_show(struct kobject *kobj, · line 1375

Quoted 8 lines
drivers/hv/vmbus_drv.c +3 -0
@@ -1368,6 +1368,9 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj,
 	if (!attribute->show)
 		return -EIO;
 
+	if (chan->state != CHANNEL_OPENED_STATE)
+		return -EINVAL;
+
 	return attribute->show(chan, buf);
 }

Thanks,

Signature · 1 line
  Vitaly