Skip to contentSkip to conversation

net: mvpp2: Use strscpy to handle stat strings

PATCH In review Maxime Chevallier 2 participants 2 messages Jun 6, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mvpp2: Use strscpy to handle stat strings

Use a safe strscpy call to copy the ethtool stat strings into the relevant buffers, instead of a memcpy that will be accessing out-of-bound data.

Fixes 118d6298f6f0 ("net: mvpp2: add ethtool GOP statistics")
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -2
index 7a67e23a2c2b..d8e5241097a9 100644
@@ -1304,8 +1304,8 @@ static void mvpp2_ethtool_get_strings(struct net_device *netdev, u32 sset,
 		int i;
 
 		for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
-			memcpy(data + i * ETH_GSTRING_LEN,
-			       &mvpp2_ethtool_regs[i].string, ETH_GSTRING_LEN);
+			strscpy(data + i * ETH_GSTRING_LEN,
+			        mvpp2_ethtool_regs[i].string, ETH_GSTRING_LEN);
 	}
 }
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw

From: Maxime Chevallier <[email protected]>
Date: Thu, 6 Jun 2019 10:42:56 +0200

Quoted 6 lines

Use a safe strscpy call to copy the ethtool stat strings into the relevant buffers, instead of a memcpy that will be accessing out-of-bound data.

Fixes 118d6298f6f0 ("net: mvpp2: add ethtool GOP statistics")

Applied and queued up for -stable.