aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2018-08-22 16:30:45 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-23 00:42:58 -0400
commit431280eebed9f5079553daf003011097763e71fd (patch)
tree13f7bee9436e2ab1ca9b6d2b14b8b7fe66da4f28 /net/ipv4/tcp_ipv4.c
parente500c6d349f7f36120886841c6f057ce248b48b2 (diff)
ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 9e041fa5c545..44c09eddbb78 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)
2517 if (res) 2517 if (res)
2518 goto fail; 2518 goto fail;
2519 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); 2519 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
2520
2521 /* Please enforce IP_DF and IPID==0 for RST and
2522 * ACK sent in SYN-RECV and TIME-WAIT state.
2523 */
2524 inet_sk(sk)->pmtudisc = IP_PMTUDISC_DO;
2525
2520 *per_cpu_ptr(net->ipv4.tcp_sk, cpu) = sk; 2526 *per_cpu_ptr(net->ipv4.tcp_sk, cpu) = sk;
2521 } 2527 }
2522 2528