From: Alice Mikityanska Wherever a GSO packet can occur, and its length is used to fill the UDP header, use udp_set_len that assigns 0 if the length doesn't fit 16 bits, so that the packet can be properly parsed and segmented later, instead of having truncated length. Signed-off-by: Alice Mikityanska --- net/ipv4/fou_core.c | 2 +- net/ipv6/fou6.c | 2 +- net/netfilter/ipvs/ip_vs_xmit.c | 2 +- net/netfilter/nf_conntrack_proto_udp.c | 4 +++- net/netfilter/nf_nat_helper.c | 2 +- net/psp/psp_main.c | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 7aeb6efbfc44..d934860e1f34 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -1043,7 +1043,7 @@ static void fou_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e, uh->dest = e->dport; uh->source = sport; - udp_set_len_short(uh, skb->len); + udp_set_len(uh, skb->len); udp_set_csum(!(e->flags & TUNNEL_ENCAP_FLAG_CSUM), skb, fl4->saddr, fl4->daddr, skb->len); diff --git a/net/ipv6/fou6.c b/net/ipv6/fou6.c index abcf23500299..3c79fe8aba1b 100644 --- a/net/ipv6/fou6.c +++ b/net/ipv6/fou6.c @@ -30,7 +30,7 @@ static void fou6_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e, uh->dest = e->dport; uh->source = sport; - udp_set_len_short(uh, skb->len); + udp_set_len(uh, skb->len); udp6_set_csum(!(e->flags & TUNNEL_ENCAP_FLAG_CSUM6), skb, &fl6->saddr, &fl6->daddr, skb->len); diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c index b460998e348e..08b0b5bfe4ec 100644 --- a/net/netfilter/ipvs/ip_vs_xmit.c +++ b/net/netfilter/ipvs/ip_vs_xmit.c @@ -1089,7 +1089,7 @@ ipvs_gue_encap(struct net *net, struct sk_buff *skb, dport = cp->dest->tun_port; udph->dest = dport; udph->source = sport; - udp_set_len_short(udph, skb->len); + udp_set_len(udph, skb->len); udph->check = 0; *next_protocol = IPPROTO_UDP; diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index e9bd1632304f..ca7d259ded8b 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c @@ -45,9 +45,11 @@ static bool udp_validate_len(struct sk_buff *skb, const struct udphdr *hdr, unsigned int dataoff) { - unsigned int udplen = udp_get_len_short(hdr); + unsigned int udplen = ntohs(hdr->len); unsigned int skblen = skb->len - dataoff; + if (!udplen && skblen >= GRO_LEGACY_MAX_SIZE) + return true; if (udplen > skblen || udplen < sizeof(*hdr)) return false; return true; diff --git a/net/netfilter/nf_nat_helper.c b/net/netfilter/nf_nat_helper.c index 3853f41db499..ec34a2f4baa8 100644 --- a/net/netfilter/nf_nat_helper.c +++ b/net/netfilter/nf_nat_helper.c @@ -161,7 +161,7 @@ nf_nat_mangle_udp_packet(struct sk_buff *skb, /* update the length of the UDP packet */ datalen = skb->len - protoff; - udp_set_len_short(udph, datalen); + udp_set_len(udph, datalen); /* fix udp checksum if udp checksum was previously calculated */ if (!udph->check && skb->ip_summed != CHECKSUM_PARTIAL) diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c index 2415b75a2a12..c9c60cb69daa 100644 --- a/net/psp/psp_main.c +++ b/net/psp/psp_main.c @@ -207,7 +207,7 @@ static void psp_write_headers(struct net *net, struct sk_buff *skb, __be32 spi, uh->source = udp_flow_src_port(net, skb, 0, 0, false); } uh->check = 0; - udp_set_len_short(uh, udp_len); + udp_set_len(uh, udp_len); psph->nexthdr = IPPROTO_TCP; psph->hdrlen = PSP_HDRLEN_NOOPT; -- 2.52.0