Skip to content

Commit 55f5356

Browse files
ffainellidavem330
authored andcommitted
net: phy: micrel: Use strlcpy() for ethtool::get_strings
Our statistics strings are allocated at initialization without being bound to a specific size, yet, we would copy ETH_GSTRING_LEN bytes using memcpy() which would create out of bounds accesses, this was flagged by KASAN. Replace this with strlcpy() to make sure we are bound the source buffer size and we also always NUL-terminate strings. Fixes: 2b2427d ("phy: micrel: Add ethtool statistics counters") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 98409b2 commit 55f5356

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/phy/micrel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ static void kszphy_get_strings(struct phy_device *phydev, u8 *data)
664664
int i;
665665

666666
for (i = 0; i < ARRAY_SIZE(kszphy_hw_stats); i++) {
667-
memcpy(data + i * ETH_GSTRING_LEN,
668-
kszphy_hw_stats[i].string, ETH_GSTRING_LEN);
667+
strlcpy(data + i * ETH_GSTRING_LEN,
668+
kszphy_hw_stats[i].string, ETH_GSTRING_LEN);
669669
}
670670
}
671671

0 commit comments

Comments
 (0)