Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp18786pxb; Fri, 15 Jan 2021 04:50:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxow8Na9tAo9FmMZcy0ZTPCYLWCqHYj0g7zKD7HLtqGHosSeNaUlhdNUzDEEK9gfluiz9up X-Received: by 2002:a05:6402:13c8:: with SMTP id a8mr4761571edx.191.1610715025469; Fri, 15 Jan 2021 04:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715025; cv=none; d=google.com; s=arc-20160816; b=ku05Vmf1oAonm5QzvxQ0w9jyNZOiIVfwpl1/of4YrlGZBDqfH9s4glWqMWOXqzq410 EmxALHSKEsJZoiGn1nzqP6PxyDlVGFPQ7k/O7E8TqzkTk2X+pk1Gf+C7oi021TWdGf2Y 0bxkeJe4TFtv92R0vApXZGpUqGg5n8zxRVB9IrNM+ttr6k2ePGuaNgFMndmUZdBcKQB6 VNwuYI+xi5qxer1Y/H4oB1eCy6PnYUgGOWviKrA6fQDPt98/R437+bcBy5KrYdvXwfg+ J3qjz/MpQYmgE9cFy9iXUfrw8E5YviVlDvTCgn9+cV9PmNPvmnH/jxu1vc72Riq9niNo UXJQ== 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=Yjv7vyrnz+s9sx6vKmH6VZdvgLMlaM7nksPmujs+lH8=; b=g7SDAY1as8LhW3eAitLXx/KNrQwms8Qf5PYlAZexwnbQZCFGD+tqHax+l808foJLaA 3IM8TsehDULuH7rfTM7JSMxI3bTwC79ZgurK76hSApEd+RJ9qQYs6ce/WTsDpKtSrTGy 7Wc74ju/oIAwmk4hPyQZr5mq5pF/XaShfw+paEmIvOkVTJYE9fqNUrvwTamTic07DFay 1jcaPiz2mIEQ0QeHMUWTg+ai7wZvRR6Udsdm/2DxtcjTQgCaZyLFo0OtsV9xfLrVSQXu i77xVY/YI/1oxdi6WahYeCSSKIeKRP/5WaKM/eQqwQW1hhcW4RKLGJ5yJpnjGO1jHZt/ 4sLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VKBIB5it; 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 h19si4517191edt.159.2021.01.15.04.50.01; Fri, 15 Jan 2021 04:50:25 -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=VKBIB5it; 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 S1733088AbhAOMg7 (ORCPT + 99 others); Fri, 15 Jan 2021 07:36:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:43804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387900AbhAOMgz (ORCPT ); Fri, 15 Jan 2021 07:36:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B9B3F235F8; Fri, 15 Jan 2021 12:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714200; bh=4b6KTADMUszXwHiL0qLMNLUfo5ItW4HV6WRJ9pLu2Es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKBIB5itGdfoY/KVf/T03lzS3FFeweKauzCUW8bMY6ejRVKJJUs4jSVKJ4h3eDzdf WGWtrJ8UjI5MIyt9PaGCinOHeKyGS9a95l/H+a3rqXOkPv6hQdEq3YBuQcEmB9AIdS tCotG3WVoFa1rPwHUPixqb/Qyk2iLn2q/ACaMjo0= 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 5.10 028/103] net: ip: always refragment ip defragmented packets Date: Fri, 15 Jan 2021 13:27:21 +0100 Message-Id: <20210115122007.419311496@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115122006.047132306@linuxfoundation.org> References: <20210115122006.047132306@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 @@ -302,7 +302,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);