]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: mvpp2: Use strscpy to handle stat strings
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Thu, 6 Jun 2019 08:42:56 +0000 (10:42 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit d37acd5aa99c57505b64913e0e2624ec3daed8c5 ]

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")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/marvell/mvpp2.c

index 169f57022c72e16f8058db1020a4856f4639e61f..9333681380cdabee7fe912108a5ecdef71468f5c 100644 (file)
@@ -4886,8 +4886,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);
        }
 }