All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state
@ 2018-08-22 20:30 Eric Dumazet
  2018-08-23  4:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-08-22 20:30 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, Geoff Alexander, Eric Dumazet, Eric Dumazet

tcp uses per-cpu (and per namespace) sockets (net->ipv4.tcp_sk) internally
to send some control packets.

1) RST packets, through tcp_v4_send_reset()
2) ACK packets in SYN-RECV and TIME-WAIT state, through tcp_v4_send_ack()

These packets assert IP_DF, and also use the hashed IP ident generator
to provide an IPv4 ID number.

Geoff Alexander reported this could be used to build off-path attacks.

These packets should not be fragmented, since their size is smaller than
IPV4_MIN_MTU. Only some tunneled paths could eventually have to fragment,
regardless of inner IPID.

We really can use zero IPID, to address the flaw, and as a bonus,
avoid a couple of atomic operations in ip_idents_reserve()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Geoff Alexander <alexandg@cs.unm.edu>
Tested-by: Geoff Alexander <alexandg@cs.unm.edu>
---
 net/ipv4/tcp_ipv4.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 9e041fa5c545367961f03fa8a9124aebbc1b6c69..44c09eddbb781c03da2417aaa925e360de01a6e9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2517,6 +2517,12 @@ static int __net_init tcp_sk_init(struct net *net)
 		if (res)
 			goto fail;
 		sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
+
+		/* Please enforce IP_DF and IPID==0 for RST and
+		 * ACK sent in SYN-RECV and TIME-WAIT state.
+		 */
+		inet_sk(sk)->pmtudisc = IP_PMTUDISC_DO;
+
 		*per_cpu_ptr(net->ipv4.tcp_sk, cpu) = sk;
 	}
 
-- 
2.18.0.1017.ga543ac7ca45-goog

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state
  2018-08-22 20:30 [PATCH net] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state Eric Dumazet
@ 2018-08-23  4:43 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-08-23  4:43 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, alexandg, eric.dumazet

From: Eric Dumazet <edumazet@google.com>
Date: Wed, 22 Aug 2018 13:30:45 -0700

> tcp uses per-cpu (and per namespace) sockets (net->ipv4.tcp_sk) internally
> to send some control packets.
> 
> 1) RST packets, through tcp_v4_send_reset()
> 2) ACK packets in SYN-RECV and TIME-WAIT state, through tcp_v4_send_ack()
> 
> These packets assert IP_DF, and also use the hashed IP ident generator
> to provide an IPv4 ID number.
> 
> Geoff Alexander reported this could be used to build off-path attacks.
> 
> These packets should not be fragmented, since their size is smaller than
> IPV4_MIN_MTU. Only some tunneled paths could eventually have to fragment,
> regardless of inner IPID.
> 
> We really can use zero IPID, to address the flaw, and as a bonus,
> avoid a couple of atomic operations in ip_idents_reserve()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Geoff Alexander <alexandg@cs.unm.edu>
> Tested-by: Geoff Alexander <alexandg@cs.unm.edu>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-23  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 20:30 [PATCH net] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state Eric Dumazet
2018-08-23  4:43 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.