Skip to content

Commit b00916b

Browse files
Kees Cookdavem330
authored andcommitted
net: clear heap allocations for privileged ethtool actions
Several other ethtool functions leave heap uncleared (potentially) by drivers. Some interfaces appear safe (eeprom, etc), in that the sizes are well controlled. In some situations (e.g. unchecked error conditions), the heap will remain unchanged in areas before copying back to userspace. Note that these are less of an issue since these all require CAP_NET_ADMIN. Cc: stable@kernel.org Signed-off-by: Kees Cook <kees.cook@canonical.com> Acked-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0aa7dea commit b00916b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/ethtool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
397397
(KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
398398
return -ENOMEM;
399399
full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
400-
indir = kmalloc(full_size, GFP_USER);
400+
indir = kzalloc(full_size, GFP_USER);
401401
if (!indir)
402402
return -ENOMEM;
403403

@@ -538,7 +538,7 @@ static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr)
538538

539539
gstrings.len = ret;
540540

541-
data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
541+
data = kzalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
542542
if (!data)
543543
return -ENOMEM;
544544

@@ -775,7 +775,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
775775
if (regs.len > reglen)
776776
regs.len = reglen;
777777

778-
regbuf = kmalloc(reglen, GFP_USER);
778+
regbuf = kzalloc(reglen, GFP_USER);
779779
if (!regbuf)
780780
return -ENOMEM;
781781

0 commit comments

Comments
 (0)