Skip to content

Commit e80bd08

Browse files
Edward Creedavem330
authored andcommitted
sfc: ensure type is valid before updating seen_gen
In the case of invalid or corrupted v2 counter update packets, efx_tc_rx_version_2() returns EFX_TC_COUNTER_TYPE_MAX. In this case we should not attempt to update generation counts as this will write beyond the end of the seen_gen array. Reported-by: coverity-bot <[email protected]> Addresses-Coverity-ID: 1527356 ("Memory - illegal accesses") Fixes: 25730d8 ("sfc: add extra RX channel to receive MAE counter updates on ef100") Signed-off-by: Edward Cree <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f22544 commit e80bd08

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/net/ethernet/sfc/tc_counters.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,15 @@ static bool efx_tc_rx(struct efx_rx_queue *rx_queue, u32 mark)
476476
goto out;
477477
}
478478

479-
/* Update seen_gen unconditionally, to avoid a missed wakeup if
480-
* we race with efx_mae_stop_counters().
481-
*/
482-
efx->tc->seen_gen[type] = mark;
483-
if (efx->tc->flush_counters &&
484-
(s32)(efx->tc->flush_gen[type] - mark) <= 0)
485-
wake_up(&efx->tc->flush_wq);
479+
if (type < EFX_TC_COUNTER_TYPE_MAX) {
480+
/* Update seen_gen unconditionally, to avoid a missed wakeup if
481+
* we race with efx_mae_stop_counters().
482+
*/
483+
efx->tc->seen_gen[type] = mark;
484+
if (efx->tc->flush_counters &&
485+
(s32)(efx->tc->flush_gen[type] - mark) <= 0)
486+
wake_up(&efx->tc->flush_wq);
487+
}
486488
out:
487489
efx_free_rx_buffers(rx_queue, rx_buf, 1);
488490
channel->rx_pkt_n_frags = 0;

0 commit comments

Comments
 (0)