Skip to content

Commit cd52667

Browse files
ffainellidavem330
authored andcommitted
net: dsa: b53: 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: 967dd82 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ce38061 commit cd52667

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data)
814814
unsigned int i;
815815

816816
for (i = 0; i < mib_size; i++)
817-
memcpy(data + i * ETH_GSTRING_LEN,
818-
mibs[i].name, ETH_GSTRING_LEN);
817+
strlcpy(data + i * ETH_GSTRING_LEN,
818+
mibs[i].name, ETH_GSTRING_LEN);
819819
}
820820
EXPORT_SYMBOL(b53_get_strings);
821821

0 commit comments

Comments
 (0)