lkml.org 
[lkml]   [2019]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] Drivers: hv: vmbus: Add mutex lock to channel show functions
    The channel level "_show" functions are vulnerable to race conditions.
    Add a mutex lock and unlock around the call to the channel level "_show"
    functions in vmbus_chan_attr_show().

    This problem was discussed here: https://lkml.org/lkml/2018/10/18/830

    Signed-off-by: Kimberly Brown <kimbrownkd@gmail.com>
    ---
    drivers/hv/vmbus_drv.c | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
    index 403fee01572c..e8189bc168da 100644
    --- a/drivers/hv/vmbus_drv.c
    +++ b/drivers/hv/vmbus_drv.c
    @@ -1414,6 +1414,7 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj,
    = container_of(attr, struct vmbus_chan_attribute, attr);
    const struct vmbus_channel *chan
    = container_of(kobj, struct vmbus_channel, kobj);
    + ssize_t ret;

    if (!attribute->show)
    return -EIO;
    @@ -1421,7 +1422,10 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj,
    if (chan->state != CHANNEL_OPENED_STATE)
    return -EINVAL;

    - return attribute->show(chan, buf);
    + mutex_lock(&vmbus_connection.channel_mutex);
    + ret = attribute->show(chan, buf);
    + mutex_unlock(&vmbus_connection.channel_mutex);
    + return ret;
    }

    static const struct sysfs_ops vmbus_chan_sysfs_ops = {
    --
    2.17.1
    \
     
     \ /
      Last update: 2019-01-22 03:09    [W:2.818 / U:0.116 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site