Skip to content

Commit 23f5740

Browse files
edumazetkuba-moo
authored andcommitted
ipv4: avoid using shared IP generator for connected sockets
ip_select_ident_segs() has been very conservative about using the connected socket private generator only for packets with IP_DF set, claiming it was needed for some VJ compression implementations. As mentioned in this referenced document, this can be abused. (Ref: Off-Path TCP Exploits of the Mixed IPID Assignment) Before switching to pure random IPID generation and possibly hurt some workloads, lets use the private inet socket generator. Not only this will remove one vulnerability, this will also improve performance of TCP flows using pmtudisc==IP_PMTUDISC_DONT Fixes: 73f156a ("inetpeer: get rid of ip_id_count") Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[email protected]> Reported-by: Ray Che <[email protected]> Cc: Willy Tarreau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 970a5a3 commit 23f5740

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

include/net/ip.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,19 +525,18 @@ static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
525525
{
526526
struct iphdr *iph = ip_hdr(skb);
527527

528+
/* We had many attacks based on IPID, use the private
529+
* generator as much as we can.
530+
*/
531+
if (sk && inet_sk(sk)->inet_daddr) {
532+
iph->id = htons(inet_sk(sk)->inet_id);
533+
inet_sk(sk)->inet_id += segs;
534+
return;
535+
}
528536
if ((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) {
529-
/* This is only to work around buggy Windows95/2000
530-
* VJ compression implementations. If the ID field
531-
* does not change, they drop every other packet in
532-
* a TCP stream using header compression.
533-
*/
534-
if (sk && inet_sk(sk)->inet_daddr) {
535-
iph->id = htons(inet_sk(sk)->inet_id);
536-
inet_sk(sk)->inet_id += segs;
537-
} else {
538-
iph->id = 0;
539-
}
537+
iph->id = 0;
540538
} else {
539+
/* Unfortunately we need the big hammer to get a suitable IPID */
541540
__ip_select_ident(net, iph, segs);
542541
}
543542
}

0 commit comments

Comments
 (0)