Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp30133pxb; Fri, 15 Jan 2021 05:07:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyibwP8QGUtch7Wupu9E7yGnF3NQzfPUv6cYJfy7hyItEjXJBKAxHbPR0M1Goq8DOoKunvT X-Received: by 2002:aa7:cd44:: with SMTP id v4mr9517272edw.156.1610716066034; Fri, 15 Jan 2021 05:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610716066; cv=none; d=google.com; s=arc-20160816; b=PTXI3rL8AqxDOYdHKsPjGPxynRLaOmdRgZ7ocjDnu811ar7bDIpUW5OwXub2MKurdQ eH0eQun8vypBx3BmgqAZP1B3BarOiYpm3i8HPWd/IJhBqN6l2S9MmAIlQcXgeIKpUVNA OugJxJsryPB3gtsxtv3RGK/TXwkFM9M8wB4mUKYW8+9gSSHJ7Bx7dgIyCH72R+af1KHW FEDQtxGceHrGMlGTEptzKVtJ5qXVIGJWiNs6O+gmdm/2vvF5i/tYnnhX3cTCQ1ah3OVS Y6hja5fE2MZnWq9zI1NnGDADNON5IALicWYkl7btrCJiAKVf1GKXzUo0eoh954qPIgBY 4YaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dTVm8u6P4YK7kbjH6+LzVUiSBX2BEUxmtnt1jGJhN/c=; b=oGWAhRl/kCSYa1/N2HgMkJO4k2SikSCLdG9kbNDg7IJKMQkmLifI0tZreeSxvvJTpW PAq1uooWTz6kvA9dM2yNZAYuBOpKS3MrfongSU0/UIp/rZSoL54xwBVRcetdCb+TbkAo iYuDtLeWbCtbtyBam8szrV9D8mYsghSDFMQnnNFTNeXY9lPycbWYwcU7QI0mM/4kapH/ 4eM+SyMM/r0Xt6UvqK9iej1QMJMByOVZteFFcHKBg86URrk+lD+rESCtiDy+SCol9EFu JZNEMpOLEjhHCz5dfHbz6eqfi2Fs7mhPw4MnmPUatfyFfQC8C6YKDE5+8mxhFiMxvsee mxIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JWknhZOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si4106193edb.12.2021.01.15.05.07.21; Fri, 15 Jan 2021 05:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JWknhZOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387548AbhAONEK (ORCPT + 99 others); Fri, 15 Jan 2021 08:04:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:37326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732743AbhAOMbj (ORCPT ); Fri, 15 Jan 2021 07:31:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 144C3224F9; Fri, 15 Jan 2021 12:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610713883; bh=pfMeXNysOzQTPDmCEc+5nOvWKPsqEUx9T2x+yAP5mpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWknhZOGYVz+FuR9i7yjl9363RpKCgVY5tIeZz1w7P8g4EbhZ3xUjIuaeCPJlXef8 3JcV1N/Nh82PahevhyygFD92FHxSprinCP2rCR0tCAPTHa0D+eNVtTTDpQmgyvlMSx QkoMU+QlmD7LEkcYu9bBGlWRtUivIfNAY00A1J2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Perle , Florian Westphal , Pablo Neira Ayuso , Jakub Kicinski Subject: [PATCH 4.14 04/28] net: ip: always refragment ip defragmented packets Date: Fri, 15 Jan 2021 13:27:41 +0100 Message-Id: <20210115121956.957845807@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121956.731354372@linuxfoundation.org> References: <20210115121956.731354372@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal [ Upstream commit bb4cc1a18856a73f0ff5137df0c2a31f4c50f6cf ] Conntrack reassembly records the largest fragment size seen in IPCB. However, when this gets forwarded/transmitted, fragmentation will only be forced if one of the fragmented packets had the DF bit set. In that case, a flag in IPCB will force fragmentation even if the MTU is large enough. This should work fine, but this breaks with ip tunnels. Consider client that sends a UDP datagram of size X to another host. The client fragments the datagram, so two packets, of size y and z, are sent. DF bit is not set on any of these packets. Middlebox netfilter reassembles those packets back to single size-X packet, before routing decision. packet-size-vs-mtu checks in ip_forward are irrelevant, because DF bit isn't set. At output time, ip refragmentation is skipped as well because x is still smaller than the mtu of the output device. If ttransmit device is an ip tunnel, the packet size increases to x+overhead. Also, tunnel might be configured to force DF bit on outer header. In this case, packet will be dropped (exceeds MTU) and an ICMP error is generated back to sender. But sender already respects the announced MTU, all the packets that it sent did fit the announced mtu. Force refragmentation as per original sizes unconditionally so ip tunnel will encapsulate the fragments instead. The only other solution I see is to place ip refragmentation in the ip_tunnel code to handle this case. Fixes: d6b915e29f4ad ("ip_fragment: don't forward defragmented DF packet") Reported-by: Christian Perle Signed-off-by: Florian Westphal Acked-by: Pablo Neira Ayuso Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -312,7 +312,7 @@ static int ip_finish_output(struct net * if (skb_is_gso(skb)) return ip_finish_output_gso(net, sk, skb, mtu); - if (skb->len > mtu || (IPCB(skb)->flags & IPSKB_FRAG_PMTU)) + if (skb->len > mtu || IPCB(skb)->frag_max_size) return ip_fragment(net, sk, skb, mtu, ip_finish_output2); return ip_finish_output2(net, sk, skb);