Skip to content

Commit e09c6a4

Browse files
committed
Merge branch 'tcp-fix-possible-crash-in-tcp_v4_err'
Eric Dumazet says: ==================== tcp: fix possible crash in tcp_v4_err() soukjin bae reported a crash in tcp_v4_err() that we root caused to a missing initialization. Second patch adds a sanity check in tcp_v4_err() to avoid future potential problems. Ignoring an ICMP message is probably better than crashing a machine. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents e928b5d + 2c4cc97 commit e09c6a4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,7 @@ void tcp_write_queue_purge(struct sock *sk)
25282528
sk_mem_reclaim(sk);
25292529
tcp_clear_all_retrans_hints(tcp_sk(sk));
25302530
tcp_sk(sk)->packets_out = 0;
2531+
inet_csk(sk)->icsk_backoff = 0;
25312532
}
25322533

25332534
int tcp_disconnect(struct sock *sk, int flags)
@@ -2576,7 +2577,6 @@ int tcp_disconnect(struct sock *sk, int flags)
25762577
tp->write_seq += tp->max_window + 2;
25772578
if (tp->write_seq == 0)
25782579
tp->write_seq = 1;
2579-
icsk->icsk_backoff = 0;
25802580
tp->snd_cwnd = 2;
25812581
icsk->icsk_probes_out = 0;
25822582
tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;

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)