2018-08-20 21:19:09

by kys

[permalink] [raw]
Subject: [PATCH] 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")

Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: K. Y. Srinivasan <[email protected]>
Cc: <[email protected]> # 4.15
---
drivers/hv/vmbus_drv.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index e6d8fdac6d8b..4bbc420d1213 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -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);
}

--
2.18.0



2018-08-30 12:00:44

by Vitaly Kuznetsov

[permalink] [raw]
Subject: Re: [PATCH] vmbus: don't return values for uninitalized channels

[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")
>
> Signed-off-by: Stephen Hemminger <[email protected]>
> Signed-off-by: K. Y. Srinivasan <[email protected]>
> Cc: <[email protected]> # 4.15

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

> ---
> drivers/hv/vmbus_drv.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index e6d8fdac6d8b..4bbc420d1213 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -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,

--
Vitaly