Skip to content

Commit fab6146

Browse files
mkubecekgregkh
authored andcommitted
net: account for current skb length when deciding about UFO
commit a5cb659bbc1c8644efa0c3138a757a1e432a4880 upstream. Our customer encountered stuck NFS writes for blocks starting at specific offsets w.r.t. page boundary caused by networking stack sending packets via UFO enabled device with wrong checksum. The problem can be reproduced by composing a long UDP datagram from multiple parts using MSG_MORE flag: sendto(sd, buff, 1000, MSG_MORE, ...); sendto(sd, buff, 1000, MSG_MORE, ...); sendto(sd, buff, 3000, 0, ...); Assume this packet is to be routed via a device with MTU 1500 and NETIF_F_UFO enabled. When second sendto() gets into __ip_append_data(), this condition is tested (among others) to decide whether to call ip_ufo_append_data(): ((length + fragheaderlen) > mtu) || (skb && skb_is_gso(skb)) At the moment, we already have skb with 1028 bytes of data which is not marked for GSO so that the test is false (fragheaderlen is usually 20). Thus we append second 1000 bytes to this skb without invoking UFO. Third sendto(), however, has sufficient length to trigger the UFO path so that we end up with non-UFO skb followed by a UFO one. Later on, udp_send_skb() uses udp_csum() to calculate the checksum but that assumes all fragments have correct checksum in skb->csum which is not true for UFO fragments. When checking against MTU, we need to add skb->len to length of new segment if we already have a partially filled skb and fragheaderlen only if there isn't one. In the IPv6 case, skb can only be null if this is the first segment so that we have to use headersize (length of the first IPv6 header) rather than fragheaderlen (length of IPv6 header of further fragments) for skb == NULL. Fixes: e89e9cf ("[IPv4/IPv6]: UFO Scatter-gather approach") Fixes: e4c5e13aa45c ("ipv6: Should use consistent conditional judgement for ip6 fragment between __ip6_append_data and ip6_finish_output") Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Acked-by: Vlad Yasevich <vyasevic@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 96cdeaa commit fab6146

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

net/ipv4/ip_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ static int __ip_append_data(struct sock *sk,
923923

924924
cork->length += length;
925925
if ((skb && skb_is_gso(skb)) ||
926-
(((length + fragheaderlen) > mtu) &&
926+
(((length + (skb ? skb->len : fragheaderlen)) > mtu) &&
927927
(skb_queue_len(queue) <= 1) &&
928928
(sk->sk_protocol == IPPROTO_UDP) &&
929929
(rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len &&

net/ipv6/ip6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static int __ip6_append_data(struct sock *sk,
13581358

13591359
cork->length += length;
13601360
if ((skb && skb_is_gso(skb)) ||
1361-
(((length + fragheaderlen) > mtu) &&
1361+
(((length + (skb ? skb->len : headersize)) > mtu) &&
13621362
(skb_queue_len(queue) <= 1) &&
13631363
(sk->sk_protocol == IPPROTO_UDP) &&
13641364
(rt->dst.dev->features & NETIF_F_UFO) &&

0 commit comments

Comments
 (0)