Skip to content

Commit ae074e2

Browse files
Edward Creedavem330
authored andcommitted
sfc: check for zero length in EF10 RX prefix
When EF10 RXDP firmware is operating in cut-through mode, packet length is not known at the time the RX prefix is generated, so it is left as zero and RX event merging is inhibited to ensure that the length is available in the RX event. However, it has been found that in certain circumstances the RX events for these packets still get merged, meaning the driver cannot read the length from the RX event, and tries to use the length from the prefix. The resulting zero-length SKBs cause crashes in GRO since commit 1d11fa6 ("net-gro: remove GRO_DROP"), so add a check to the driver to detect these zero-length RX events and discard the packet. Signed-off-by: Edward Cree <ecree.xilinx@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d8a3070 commit ae074e2

File tree

1 file changed

+15
-5
lines changed
  • drivers/net/ethernet/sfc

1 file changed

+15
-5
lines changed

drivers/net/ethernet/sfc/rx.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,26 +359,36 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
359359
/* Handle a received packet. Second half: Touches packet payload. */
360360
void __efx_rx_packet(struct efx_channel *channel)
361361
{
362+
struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);
362363
struct efx_nic *efx = channel->efx;
363364
struct efx_rx_buffer *rx_buf =
364-
efx_rx_buffer(&channel->rx_queue, channel->rx_pkt_index);
365+
efx_rx_buffer(rx_queue, channel->rx_pkt_index);
365366
u8 *eh = efx_rx_buf_va(rx_buf);
366367

367368
/* Read length from the prefix if necessary. This already
368369
* excludes the length of the prefix itself.
369370
*/
370-
if (rx_buf->flags & EFX_RX_PKT_PREFIX_LEN)
371+
if (rx_buf->flags & EFX_RX_PKT_PREFIX_LEN) {
371372
rx_buf->len = le16_to_cpup((__le16 *)
372373
(eh + efx->rx_packet_len_offset));
374+
/* A known issue may prevent this being filled in;
375+
* if that happens, just drop the packet.
376+
* Must do that in the driver since passing a zero-length
377+
* packet up to the stack may cause a crash.
378+
*/
379+
if (unlikely(!rx_buf->len)) {
380+
efx_free_rx_buffers(rx_queue, rx_buf,
381+
channel->rx_pkt_n_frags);
382+
channel->n_rx_frm_trunc++;
383+
goto out;
384+
}
385+
}
373386

374387
/* If we're in loopback test, then pass the packet directly to the
375388
* loopback layer, and free the rx_buf here
376389
*/
377390
if (unlikely(efx->loopback_selftest)) {
378-
struct efx_rx_queue *rx_queue;
379-
380391
efx_loopback_rx_packet(efx, eh, rx_buf->len);
381-
rx_queue = efx_channel_get_rx_queue(channel);
382392
efx_free_rx_buffers(rx_queue, rx_buf,
383393
channel->rx_pkt_n_frags);
384394
goto out;

0 commit comments

Comments
 (0)