From: Kees Cook Date: Mon, 11 Oct 2010 19:23:25 +0000 (-0700) Subject: net: clear heap allocations for privileged ethtool actions X-Git-Tag: firefly_0821_release~10186^2~819 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3765ba02027246e3a709990cda1b95d031e87404;p=firefly-linux-kernel-4.4.55.git net: clear heap allocations for privileged ethtool actions [ Upstream commit b00916b189d13a615ff05c9242201135992fcda3 ] 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 Acked-by: Ben Hutchings Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 5aef51eb3d1f..450862e980c8 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -311,7 +311,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) if (regs.len > reglen) regs.len = reglen; - regbuf = kmalloc(reglen, GFP_USER); + regbuf = kzalloc(reglen, GFP_USER); if (!regbuf) return -ENOMEM;