aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru>2016-08-26 06:19:34 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-27 00:40:44 -0400
commite70c70c38d7a5ced76fc8b1c4a7ccee76e9c2911 (patch)
treef0409c417d22904e551a2240f711e6ffbb4848a8
parent5c1f5b457b86a263d0e21c8f3ebe83d515e7bcce (diff)
sfc: fix potential stack corruption from running past stat bitmask
On 32-bit systems, mask is only an array of 3 longs, not 4, so don't try to write to mask[3]. Also include build-time checks in case the size of the bitmask changes. Fixes: 3c36a2aded8c ("sfc: display vadaptor statistics for all interfaces") Signed-off-by: Edward Cree <ecree@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/sfc/ef10.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index f658fee74f18..e00a669e9e09 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -1517,13 +1517,14 @@ static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask)
1517 } 1517 }
1518 1518
1519#if BITS_PER_LONG == 64 1519#if BITS_PER_LONG == 64
1520 BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 2);
1520 mask[0] = raw_mask[0]; 1521 mask[0] = raw_mask[0];
1521 mask[1] = raw_mask[1]; 1522 mask[1] = raw_mask[1];
1522#else 1523#else
1524 BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 3);
1523 mask[0] = raw_mask[0] & 0xffffffff; 1525 mask[0] = raw_mask[0] & 0xffffffff;
1524 mask[1] = raw_mask[0] >> 32; 1526 mask[1] = raw_mask[0] >> 32;
1525 mask[2] = raw_mask[1] & 0xffffffff; 1527 mask[2] = raw_mask[1] & 0xffffffff;
1526 mask[3] = raw_mask[1] >> 32;
1527#endif 1528#endif
1528} 1529}
1529 1530