From patchwork Tue Oct 24 14:26:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 157528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1980918vqx; Tue, 24 Oct 2023 07:27:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFplwMSyj0e4woABD17bFMM5AEipwUvBT8VzsH/o9HFppKysLUIxyeQdgJ7FahYVTWI5h3m X-Received: by 2002:a17:902:e5c8:b0:1ca:85ae:3b4f with SMTP id u8-20020a170902e5c800b001ca85ae3b4fmr11214612plf.55.1698157631363; Tue, 24 Oct 2023 07:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698157631; cv=none; d=google.com; s=arc-20160816; b=w1WB1OWwgCMpNsMadoq6JtTMAShCoSjru7c1tPrZx4CIx6CnoToUD0cUCM5Y6kaHYp /gt8SwZ0MiaDUxVIrGoU73EZYw0OzsrbXI77ZDrmOPTpaW9uWSjiGY0RWD2QdV8WF/bV BMWVw8KMn/Ld7f3Vb4M5yKMJ55/eTRYErJ2e2NQEuv4PDqvzRjLqPAZemfvudCYmfHnf t6G/WRzG9iXOTS9WMf+8oCrdOwY5SRK8rdfVMCF0KTdNqvktj36rFKsL0TShs/2aqk6u Hj4fYfsaL2JlO5bwbSDDH028IEaysnfUsp9aZCGsCVzYhU5P/SqZyVH+fAvSPSFphzqx uytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6S93RbRglo4zJtt34VMTicjVThmJc0ap31UZOgLJcsE=; fh=pcqFZQYW2ZOvrJzL6iYbdBSsYjMBR+cDRZVlzaRzt/k=; b=HA5RCun3PsMl916DcghVsYM+HgDqheU8rQTS3Bl7aZjPdpw1V9lKR3oTYIFzbpjLqK +7i4iEkWyx12tCgjgCZNo8FWlYfitt/VfgG7pPTvDwEeZ97PCneIw4nkJFlbXQpAJ/is 5exC0yGRQGqtdpkKV+WBbWVfyCB7aikLGbCCJIbfrrec4BA3wHRLVK4cZ3PcsCFrf2SU 3HzGo91VBpQB5Ppzzr7ihICxOCixVFM9O8ZewuhWLZ8khLzaxJevfFmrI4ud6ziVmHEZ IY21pZ8jP1yfwwhkdJc84cHWLzKRUpVHl3ihilAd0MMc3bVcRiwa4mjbR2MQY1/6tMeD /vcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=d3i0xTrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s2-20020a170902ea0200b001b829a32f2dsi8864119plg.457.2023.10.24.07.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 07:27:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=d3i0xTrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7597D806B716; Tue, 24 Oct 2023 07:27:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343716AbjJXO0y (ORCPT + 26 others); Tue, 24 Oct 2023 10:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjJXO0v (ORCPT ); Tue, 24 Oct 2023 10:26:51 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1DF12C for ; Tue, 24 Oct 2023 07:26:45 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-7788ebea620so298807185a.3 for ; Tue, 24 Oct 2023 07:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1698157604; x=1698762404; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6S93RbRglo4zJtt34VMTicjVThmJc0ap31UZOgLJcsE=; b=d3i0xTrtHY7fyNjAnemlo9hK6NiX9t3PE31O1zWq9PgxcDRJqY1q9oMNBafmkdCxgk 0XG+xpmDScIs8nxH+oOpTD+6eI1p2wLTjzvH2Sd56yxz1Ue0lfAtGjCSGQ7skl9ldEGZ +HXu/IFuD0LmkZHj74zLH8g++vRotkEacJ5c3sPDCGJFjX7H4NkR5/X6KgFP0x91pSwN Z5NP9/u/l2BKIm6D6AXwt+oFLMRGt9mijYipuDlMM+Bk9uoWDbxsvcqaOxn90fmDHHY9 reFmWU0jrLsHlDKGDMrEo6cXWq7bSgDQ8M2DH20mWqPKUYaCkzAuyLrHvt9yNtxOJPlw 6S+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698157604; x=1698762404; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6S93RbRglo4zJtt34VMTicjVThmJc0ap31UZOgLJcsE=; b=oXn6PjzyHlDdTbtB4PYct35+0Rh/LQkyakYdvRgie+PwdZEoifzJCFnnqckK69S2kt q+lFK0V01WTLy3m2eiSWf/92+Uy2o0Kf6V6IFHR7k06JgjXTr+ug0DM+Ho9hUCl+rHy/ k9bnekSGtF9+8qfqoUbAB5o2e3iKz+1V2jckoX7gvU9Fu0drtqh3TNq08lc2kgKQk+Zk 4Wunu2PLFb07X3rwf/qWcXlzyXX/W+ChbtA9A2RJkdEo+cIF5KQY+6fuVR8IoWYGMeoT Wky23++nx0UMThJ1y0QJ7Lf6FemU+2k41bNSpi2hR3QpRNtul9YdLhn7wXubjAXkvf4h 4L+A== X-Gm-Message-State: AOJu0YyS1GGWZpJK5t2wlcuNNjd3418ylSLXmVPTf6O1mG50WQ+U9wPX o+wYeg9UWueq3EWePAlrTeXQtQ== X-Received: by 2002:a05:620a:d96:b0:767:c572:ab10 with SMTP id q22-20020a05620a0d9600b00767c572ab10mr13854304qkl.35.1698157604465; Tue, 24 Oct 2023 07:26:44 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id l15-20020a05620a0c0f00b0077892023fc5sm3466575qki.120.2023.10.24.07.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 07:26:43 -0700 (PDT) Date: Tue, 24 Oct 2023 07:26:40 -0700 From: Yan Zhai To: netdev@vger.kernel.org Cc: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Aya Levin , Tariq Toukan , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Florian Westphal , Willem de Bruijn , Alexander H Duyck Subject: [PATCH v5 net-next 3/3] ipv6: avoid atomic fragment on GSO packets Message-ID: <90912e3503a242dca0bc36958b11ed03a2696e5e.1698156966.git.yan@cloudflare.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 07:27:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780647336407546053 X-GMAIL-MSGID: 1780647336407546053 When the ipv6 stack output a GSO packet, if its gso_size is larger than dst MTU, then all segments would be fragmented. However, it is possible for a GSO packet to have a trailing segment with smaller actual size than both gso_size as well as the MTU, which leads to an "atomic fragment". Atomic fragments are considered harmful in RFC-8021. An Existing report from APNIC also shows that atomic fragments are more likely to be dropped even it is equivalent to a no-op [1]. Add an extra check in the GSO slow output path. For each segment from the original over-sized packet, if it fits with the path MTU, then avoid generating an atomic fragment. Link: https://www.potaroo.net/presentations/2022-03-01-ipv6-frag.pdf [1] Fixes: b210de4f8c97 ("net: ipv6: Validate GSO SKB before finish IPv6 processing") Reported-by: David Wragg Signed-off-by: Yan Zhai --- net/ipv6/ip6_output.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 4010dd97aaf8..a722a43dd668 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -164,7 +164,13 @@ ip6_finish_output_gso_slowpath_drop(struct net *net, struct sock *sk, int err; skb_mark_not_on_list(segs); - err = ip6_fragment(net, sk, segs, ip6_finish_output2); + /* Last GSO segment can be smaller than gso_size (and MTU). + * Adding a fragment header would produce an "atomic fragment", + * which is considered harmful (RFC-8021). Avoid that. + */ + err = segs->len > mtu ? + ip6_fragment(net, sk, segs, ip6_finish_output2) : + ip6_finish_output2(net, sk, segs); if (err && ret == 0) ret = err; }