Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1610974rda; Mon, 23 Oct 2023 19:36:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7NYVqaHOYHazGlV96aX877jIVBadQjDv46l6d9O2PTBYfys8hjbuQPxAg6Lzilp8w6xIi X-Received: by 2002:a05:6808:1b0b:b0:3b2:f393:dab1 with SMTP id bx11-20020a0568081b0b00b003b2f393dab1mr11461212oib.21.1698114980220; Mon, 23 Oct 2023 19:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698114980; cv=none; d=google.com; s=arc-20160816; b=WntLf1PEDp4YblWlifgZ1T5Yxsbu5mT8g1slX+cyL/0r0D2qeq+ZOFC4+Kf/uQN2xL pHuupFNvy8VKJ3KkNlgP/ahm4DCQ3lp1VqOWlo68fOW23z+nOPrBRNeVu3mFqWe216W4 N0+l+YRsHXORzLsKI6+uO0gR6SOLrVDnRnX+bxPuxJFXS2Tr9nGLWPnOjPSZBzP3J852 +/da3U3BxnQjgjbmavNfUKY4fUSgU1ES9OysH2RtUE17iaQ96X9reaOFBrbCf4JU2A11 u/BA1eTHuI58pjPc4QT/nGxdBpCPvxm+vtjp9IdySgrvzFw1L3Zu6FPMrGF+sBLiL/YM 36dA== 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=NQRaodA+dFnFgBLwvZTABfG5SY/HLV13fWmDclw4I4C143HkedhfhuhLhgRvx5vXVE jittiiaqo9GlljVYIOnN9EGs/ulDPA5m1pxfpJJ+1t+GvkMsQyV/9dpU8onB2+8IsFY8 Rfk173XyuFZaxUWP9FmyXwL+1uerBN8fHuxx+VVmOx/xawvqtjgDFGdagBqFNk+O/jro Pmt0Gx5ETTf0W+x9+MqH8UuNF2Cn9J8EnfD+yKnWG1d0pYCzn4/S4qzU5IEH08hJIXtF MFmzlisvKZw4Wmx9tAyGWJDw/Z5ssXGbvZo2zxs6NVE+qp89mUno5PBMzZ3XNeWnbtIx Lmfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=WCu9otX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h4-20020a636c04000000b005b7f339119fsi7619830pgc.589.2023.10.23.19.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 19:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=WCu9otX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 1E709804B384; Mon, 23 Oct 2023 19:36:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbjJXCf4 (ORCPT + 99 others); Mon, 23 Oct 2023 22:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232082AbjJXCfq (ORCPT ); Mon, 23 Oct 2023 22:35:46 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5B110C3 for ; Mon, 23 Oct 2023 19:35:40 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-77774120c6eso259524785a.2 for ; Mon, 23 Oct 2023 19:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1698114939; x=1698719739; 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=WCu9otX47GCdVRdugIJIAODwuN1dOZ9H2eEAtQfYrgUmi2E9JeCLwzPF9328sqKmM7 RdXiUp/zbaF1EgGI/YQT39EY5C64RCCiqM6ztsE1SE4J2ZkWT6e54ghifIPsFHHS1e/g bC1hUwswNLjBiw4FkvBN20kAz5K9pIdbW3EUNMIWbpvIohA3HlQp893nJGEtp3j/BSE9 0Uj/MPZ7Tg2ppgri9wn5LVowrgCZrr/6rczgvFTtx11L6vtw2v70aFEEY92OwUfGkDAc nXjt8OkTaT0zQQPrMYw53MCntTldvVX2t8RBeKCA0sHftL9TPi/itqIUOw3E77n2gAkM Gnbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698114939; x=1698719739; 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=PrFEi7KJhFEVrG+Cs+epmD0bMwxMeGNgsVn82GVad6lavHC6sl5XpJNaE3rM6aulwQ vJvdZytP1VMW5l6K6f6rWjsUizcayXF6hygtaxQxNGCF6VDBkg92EuQ890ftgihLAQvJ LM372vCzCzPezm3vtiadF0iEtWmgBUVpukqTf2QoWsCAVM9qzikNyK0wNCaMd5fabzn3 2UcHFwe/WPMHcAq5xVXCoiu1XvSdxhcvJnU4+6bFjdum30pSgft8yodHcgnquJVvu5b3 SJFHmtylHxv3JtlIcA+uTS+Pn40aVVC4mgDQ+0DWOVi/gq+Kp7BY1UdZSmcWuROPc0w+ IWIg== X-Gm-Message-State: AOJu0YxU98KNvwfctunEcK7AO1VPuFd8TUQyMOoEYK0Uewe98lwoKCYc BK2gWCXdUZOGKSyNxWgR+dLUwg== X-Received: by 2002:a05:620a:24cb:b0:775:9e64:f5be with SMTP id m11-20020a05620a24cb00b007759e64f5bemr12393344qkn.55.1698114939293; Mon, 23 Oct 2023 19:35:39 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id e6-20020a05620a208600b007742218dc42sm3122060qka.119.2023.10.23.19.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 19:35:38 -0700 (PDT) Date: Mon, 23 Oct 2023 19:35:37 -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 v4 net-next 3/3] ipv6: avoid atomic fragment on GSO packets Message-ID: <6b2347a888c8b2d8f259dbb4662c4995ba9a505e.1698114636.git.yan@cloudflare.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 23 Oct 2023 19:36:14 -0700 (PDT) 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; } -- 2.30.2