tcp: fix possible crash in tcp_v4_err()
Subsystems (3)
cover 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.
Eric Dumazet (2):
tcp: clear icsk_backoff in tcp_write_queue_purge()
tcp: tcp_v4_err() should be more careful
net/ipv4/tcp.c | 2 +- net/ipv4/tcp_ipv4.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
PATCH 1/2 tcp: clear icsk_backoff in tcp_write_queue_purge()
soukjin bae reported a crash in tcp_v4_err() handling ICMP_DEST_UNREACH after tcp_write_queue_head(sk) returned a NULL pointer.
Current logic should have prevented this :
if (seq != tp->snd_una || !icsk->icsk_retransmits ||
!icsk->icsk_backoff || fastopen)
break;Problem is the write queue might have been purged
and icsk_backoff has not been cleared.
--- net/ipv4/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp.c +1 -1
@@ -2528,6 +2528,7 @@ void tcp_write_queue_purge(struct sock *sk)sk_mem_reclaim (sk);tcp_clear_all_retrans_hints (tcp_sk (sk));tcp_sk (sk)->packets_out =0 ; +inet_csk (sk)->icsk_backoff =0 ; }int tcp_disconnect (struct sock *sk,int flags)
@@ -2576,7 +2577,6 @@ int tcp_disconnect(struct sock *sk, int flags) tp->write_seq += tp->max_window +2 ;if (tp->write_seq ==0 ) tp->write_seq =1 ; - icsk->icsk_backoff =0 ; tp->snd_cwnd =2 ; icsk->icsk_probes_out =0 ; tp->snd_ssthresh =TCP_INFINITE_SSTHRESH ;
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
Re: [PATCH net 1/2] tcp: clear icsk_backoff in tcp_write_queue_purge()
Quoted 11 lines · Eric Dumazet
soukjin bae reported a crash in
tcp_v4_err()handlingICMP_DEST_UNREACHaftertcp_write_queue_head(sk)returned a NULL pointer.Current logic should have prevented this :
if (seq != tp->snd_una || !icsk->icsk_retransmits || !icsk->icsk_backoff || fastopen) break;
Quoted 8 lines
Problem is the write queue might have been purged
andicsk_backoffhas not been cleared.Signed-off-by Eric Dumazet <[email protected]>Reported-by soukjin bae <[email protected]>--- net/ipv4/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks!
neal
PATCH 2/2 tcp: tcp_v4_err() should be more careful
In reply to Eric DumazetICMP 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.
--- net/ipv4/tcp_ipv4.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp_ipv4.c +4 -1
@@ -536,12 +536,15 @@ int tcp_v4_err(struct sk_buff *icmp_skb, u32 info)if (sock_owned_by_user (sk))break ; + skb =tcp_rtx_queue_head (sk); +if (WARN_ON_ONCE (!skb)) +break ; + icsk->icsk_backoff--; icsk->icsk_rto = tp->srtt_us ?__tcp_set_rto (tp) :TCP_TIMEOUT_INIT ; icsk->icsk_rto =inet_csk_rto_backoff (icsk,TCP_RTO_MAX ); - skb =tcp_rtx_queue_head (sk);tcp_mstamp_refresh (tp); delta_us = (u32)(tp->tcp_mstamp -tcp_skb_timestamp_us (skb));
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
Re: [PATCH net 2/2] tcp: tcp_v4_err() should be more careful
Quoted 5 lines · Eric Dumazet
ICMP handlers are not very often stressed, we should make them more resilient to bugs that might surface in the future.
Quoted 8 lines
If there is no packet in retransmit queue, we should avoid a NULL deref.
Signed-off-by Eric Dumazet <[email protected]>Reported-by soukjin bae <[email protected]>--- net/ipv4/tcp_ipv4.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Thanks!
neal
Soheil Hassas Yeganeh
Acked-byRe: [PATCH net 2/2] tcp: tcp_v4_err() should be more careful
Quoted 10 lines · Neal Cardwell
Quoted 8 lines · Eric Dumazet
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.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Eric Dumazet <[email protected]>Reported-by soukjin bae <[email protected]>--- net/ipv4/tcp_ipv4.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Acked-by Neal Cardwell <[email protected]>
Thanks you for the fix, Eric!
Quoted 4 lines
Thanks!
neal
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Fri, 15 Feb 2019 13:36:19 -0800
Quoted 6 lines
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.
Series applied, thanks Eric.
Want me to queue these up for -stable?
Quoted 6 lines · David Miller
From: Eric Dumazet <[email protected]>
Date: Fri, 15 Feb 2019 13:36:19 -0800Quoted 3 lines
soukjin bae reported a crash in
tcp_v4_err()that we root caused to a missing initialization.
Quoted 8 lines
Quoted 3 lines
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.Series applied, thanks Eric.
Want me to queue these up for -stable?
Yes please, I put no Fixes: tag because it seemed to be a day-0 bug.
Thanks !
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Sun, 17 Feb 2019 18:20:21 -0800
Quoted 13 lines · David Miller
Quoted 10 lines
From: Eric Dumazet <[email protected]>
Date: Fri, 15 Feb 2019 13:36:19 -0800Quoted 6 lines
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.
Quoted 6 lines
Quoted 4 lines
Series applied, thanks Eric.
Want me to queue these up for -stable?
Yes please, I put no Fixes: tag because it seemed to be a day-0 bug.
Done.