sfc: don't try and read ef10 data on non-ef10 NIC
authorBert Kenward <bkenward@solarflare.com>
Tue, 15 Aug 2017 13:55:32 +0000 (14:55 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Aug 2017 00:19:34 +0000 (17:19 -0700)
commit61deee962896f7eb547adc66ef09c8f1e7ddf7d7
treea342ee636b165b5ef500aa18d79f2ff55f43427c
parentc90e95147c27b1780e76c6e8fea1b5c78d7d387f
sfc: don't try and read ef10 data on non-ef10 NIC

The MAC stats command takes a port ID, which doesn't exist on
pre-ef10 NICs (5000- and 6000- series). This is extracted from the
NIC specific data; we misinterpret this as the ef10 data structure,
causing us to read potentially unallocated data. With a KASAN kernel
this can cause errors with:
   BUG: KASAN: slab-out-of-bounds in efx_mcdi_mac_stats

Fixes: 0a2ab4d988d7 ("sfc: set the port-id when calling MC_CMD_MAC_STATS")
Reported-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Bert Kenward <bkenward@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/mcdi_port.c