ethtool: ioctl: Use array_size() in copy_to_user()
Use array_size() helper instead of the open-coded version in copy_to_user(). These sorts of multiplication factors need to be wrapped in array_size(). This issue was found with the help of Coccinelle and, audited and fixed manually. Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
This commit is contained in:
parent
97e29f899f
commit
7a28153948
|
@ -1881,7 +1881,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
|
||||||
if (copy_to_user(useraddr, &stats, sizeof(stats)))
|
if (copy_to_user(useraddr, &stats, sizeof(stats)))
|
||||||
goto out;
|
goto out;
|
||||||
useraddr += sizeof(stats);
|
useraddr += sizeof(stats);
|
||||||
if (n_stats && copy_to_user(useraddr, data, n_stats * sizeof(u64)))
|
if (n_stats && copy_to_user(useraddr, data, array_size(n_stats, sizeof(u64))))
|
||||||
goto out;
|
goto out;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -1937,7 +1937,7 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
|
||||||
if (copy_to_user(useraddr, &stats, sizeof(stats)))
|
if (copy_to_user(useraddr, &stats, sizeof(stats)))
|
||||||
goto out;
|
goto out;
|
||||||
useraddr += sizeof(stats);
|
useraddr += sizeof(stats);
|
||||||
if (n_stats && copy_to_user(useraddr, data, n_stats * sizeof(u64)))
|
if (n_stats && copy_to_user(useraddr, data, array_size(n_stats, sizeof(u64))))
|
||||||
goto out;
|
goto out;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue