Skip to content

Commit 2c4cc97

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp: tcp_v4_err() should be more careful
ICMP handlers are not very often stressed, we should make them more resilient to bugs that might surface in the future. If there is no packet in retransmit queue, we should avoid a NULL deref. Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: soukjin bae <soukjin.bae@samsung.com> Acked-by: Neal Cardwell <ncardwell@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 04c0311 commit 2c4cc97

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,15 @@ int tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
536536
if (sock_owned_by_user(sk))
537537
break;
538538

539+
skb = tcp_rtx_queue_head(sk);
540+
if (WARN_ON_ONCE(!skb))
541+
break;
542+
539543
icsk->icsk_backoff--;
540544
icsk->icsk_rto = tp->srtt_us ? __tcp_set_rto(tp) :
541545
TCP_TIMEOUT_INIT;
542546
icsk->icsk_rto = inet_csk_rto_backoff(icsk, TCP_RTO_MAX);
543547

544-
skb = tcp_rtx_queue_head(sk);
545548

546549
tcp_mstamp_refresh(tp);
547550
delta_us = (u32)(tp->tcp_mstamp - tcp_skb_timestamp_us(skb));

0 commit comments

Comments
 (0)