lkml.org 
[lkml]   [2021]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.12 036/110] net: ethtool: clear heap allocations for ethtool function
    Date
    From: Austin Kim <austindh.kim@gmail.com>

    [ Upstream commit 80ec82e3d2c1fab42eeb730aaa7985494a963d3f ]

    Several ethtool functions leave heap uncleared (potentially) by
    drivers. This will leave the unused portion of heap unchanged and
    might copy the full contents back to userspace.

    Signed-off-by: Austin Kim <austindh.kim@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    net/ethtool/ioctl.c | 10 +++++-----
    1 file changed, 5 insertions(+), 5 deletions(-)

    diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
    index 2603966da904..e910890a868c 100644
    --- a/net/ethtool/ioctl.c
    +++ b/net/ethtool/ioctl.c
    @@ -1421,7 +1421,7 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
    if (eeprom.offset + eeprom.len > total_len)
    return -EINVAL;

    - data = kmalloc(PAGE_SIZE, GFP_USER);
    + data = kzalloc(PAGE_SIZE, GFP_USER);
    if (!data)
    return -ENOMEM;

    @@ -1486,7 +1486,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
    if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
    return -EINVAL;

    - data = kmalloc(PAGE_SIZE, GFP_USER);
    + data = kzalloc(PAGE_SIZE, GFP_USER);
    if (!data)
    return -ENOMEM;

    @@ -1765,7 +1765,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
    return -EFAULT;

    test.len = test_len;
    - data = kmalloc_array(test_len, sizeof(u64), GFP_USER);
    + data = kcalloc(test_len, sizeof(u64), GFP_USER);
    if (!data)
    return -ENOMEM;

    @@ -2281,7 +2281,7 @@ static int ethtool_get_tunable(struct net_device *dev, void __user *useraddr)
    ret = ethtool_tunable_valid(&tuna);
    if (ret)
    return ret;
    - data = kmalloc(tuna.len, GFP_USER);
    + data = kzalloc(tuna.len, GFP_USER);
    if (!data)
    return -ENOMEM;
    ret = ops->get_tunable(dev, &tuna, data);
    @@ -2473,7 +2473,7 @@ static int get_phy_tunable(struct net_device *dev, void __user *useraddr)
    ret = ethtool_phy_tunable_valid(&tuna);
    if (ret)
    return ret;
    - data = kmalloc(tuna.len, GFP_USER);
    + data = kzalloc(tuna.len, GFP_USER);
    if (!data)
    return -ENOMEM;
    if (phy_drv_tunable) {
    --
    2.30.2
    \
     
     \ /
      Last update: 2021-06-28 16:21    [W:2.594 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site