Home Home > GIT Browse > openSUSE-15.0
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-07-18 08:26:13 +0200
committerJiri Slaby <jslaby@suse.cz>2019-07-18 09:30:36 +0200
commit64b42dc06c070d390d453bac6bdfda12dd50d337 (patch)
tree4d3b4493f3963974d24502571714b9ee0c8271e4
parent04ecac82115fa4b0337d4d60de0274f386d0baf1 (diff)
ethtool: fix potential userspace buffer overflow
(networking-stable-19_06_09). suse-commit: 185825154198bb6f630138a4bf50a2b0a873c045
-rw-r--r--net/core/ethtool.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 0fb534943da5..9c469307fe63 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1427,13 +1427,16 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
return -ENOMEM;
}
+ if (regs.len < reglen)
+ reglen = regs.len;
+
ops->get_regs(dev, &regs, regbuf);
ret = -EFAULT;
if (copy_to_user(useraddr, &regs, sizeof(regs)))
goto out;
useraddr += offsetof(struct ethtool_regs, data);
- if (regbuf && copy_to_user(useraddr, regbuf, regs.len))
+ if (copy_to_user(useraddr, regbuf, reglen))
goto out;
ret = 0;