Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp802548rdb; Thu, 19 Oct 2023 22:33:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNeuNZn9ytINRYkIwHUgNMdrOpzTBRQD2HFitgUBcvstfJ15QjeGMUAJi6gUhBY/tWlXmD X-Received: by 2002:a17:90a:4f:b0:27c:facc:e3eb with SMTP id 15-20020a17090a004f00b0027cfacce3ebmr931707pjb.31.1697779995642; Thu, 19 Oct 2023 22:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697779995; cv=none; d=google.com; s=arc-20160816; b=Y1BO1Cc7uewFFCQHH5wp5xz0i3e8PCr6XzZ12xZd4E16zRlZTSODg87wqArwKxXcai me3RmIGR1YnI9Z8g3RmQtkbKfAId4FWh8KrKjUY5wjdvT++UFAM3nxxCbkmGffxELX9h AoH64sRxQ1nk4oyrrWHTWyjRGwK2N55YrBC4KOHZEhWkLdC9skl5k3euFNjQalL2hNtC U3bn1o7pgAsuxgbTv1LKaZNfQv1TuDPAxEHJOr90Cj8tYM6nE2/FJdIpyn8O9VDgJxZh 36VJpEGrug0sOSq8pLee3Lpu5G/ME53uTMExa2By5rI/VyBFgIAqXnNd+rneihdTUroA eKLw== 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=QERO0uRdQXqqSaQdJAhee2LXGn28nhRHE84yn6ioXDc=; fh=pcqFZQYW2ZOvrJzL6iYbdBSsYjMBR+cDRZVlzaRzt/k=; b=GZAeB5a9a+Amk1Pmr/7LAnwBQP/R9xVr1dKrBRIa3r/XAPoagz/NZ71CWMIFfFEQZG JCN7CzHoU4YsEwIIohh19La+ynJeicOdQXfGkfRXu8ttdJ9GgxHX8Umo4mnUmLUkBIyd AjJq6knpJUI+nKq7WLi1r/LC58iq1LqqF1UvckZfPUKbFa480hRvPq/hMRg/mWLSpICk 9ql7OG5LWokXT313J/3EhlCJkyjpljuTq/InM+mZzpiiVtjNGA2PDKpzd+Ajef75SCQh X7jioz11vOGG8PC1VQwq+id8rhWcNV+99tjBO2l7bz694Hq3iIR6K4+oI0EOATSHVYz1 M4CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=UCHRbXYL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id pg9-20020a17090b1e0900b0027df430a30esi3910770pjb.162.2023.10.19.22.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 22:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=UCHRbXYL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1589D81C36FF; Thu, 19 Oct 2023 22:33:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346684AbjJTFc7 (ORCPT + 99 others); Fri, 20 Oct 2023 01:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346645AbjJTFc4 (ORCPT ); Fri, 20 Oct 2023 01:32:56 -0400 Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33E70D51 for ; Thu, 19 Oct 2023 22:32:54 -0700 (PDT) Received: by mail-ua1-x92c.google.com with SMTP id a1e0cc1a2514c-7b6d6773d05so173403241.2 for ; Thu, 19 Oct 2023 22:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1697779973; x=1698384773; 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=QERO0uRdQXqqSaQdJAhee2LXGn28nhRHE84yn6ioXDc=; b=UCHRbXYL3xC0knyXFuBAsnyrkLGlT5t1Rqg+cpKWHrQednZoHGoTfiInP7UE+NCSFR wXSUe6Jwu7zzaVd3n85LoZnXW8+dqlE1Bhuxl3jPFfvL6x46DSNj9/D3DLF2LqmuCB9D tWbot+5hrUbZVTCTn349B4xeWIal6d8nHMFgT+1sGLA7ZjBc5ojYa5D9rR9B8t5ub5VW NV0+7zd6FNrsiehybQSpW6+JXRZkUN448cicU2ypFjj3plmy96MfLdNhMBjvLdQQpkcG wiKlBsYehe+nSW73EcWYNU+qIicC6wCqfKAZSWXlkk4Az0wwxr7oLzYz2pnDrUz+I0OD VnwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697779973; x=1698384773; 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=QERO0uRdQXqqSaQdJAhee2LXGn28nhRHE84yn6ioXDc=; b=aqQ+LsCZoMiYLBEGsYOTp+vGHqfqYecB+bporfHrgE8OZSC7976KFkEMSRumIjNJYG t4WpeH9zbLKsJJKk8O5V4KwCJbopmTFd6NeAvBw7GCf5Sym8EVQAxvY3SI1k5sx2NGc2 YohNR+8JdUn1g1qoAgWkz2KZENYCPdBNQLdK0X3F09XzLsWxYMLbowF3zkz76Phz49qY JAnGAxlN2pdmfmMXQYT10qtHMyTsShpjnAG2p8zqS0y16ulTxzAH0r5HEEZEqLNrjstd dE2/56xE1SphCBiXB53fK70i/9FyoGTjalE6pVrfb2hDzFCHx40T20d6S06XnjmOhIpg GctQ== X-Gm-Message-State: AOJu0YxiDwRHEwcEZltAN6po6lp/lGU/+Y8jRwlXGLuWAeMWDF/Mwgy1 Q231svhk+SYt9Ffn86a5yuf2HA== X-Received: by 2002:a67:ae05:0:b0:452:5798:64bd with SMTP id x5-20020a67ae05000000b00452579864bdmr920744vse.35.1697779973258; Thu, 19 Oct 2023 22:32:53 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id vq6-20020a05620a558600b0076e672f535asm359098qkn.57.2023.10.19.22.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 22:32:52 -0700 (PDT) Date: Thu, 19 Oct 2023 22:32:51 -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 v3 net-next 3/3] ipv6: avoid atomic fragment on GSO packets Message-ID: <77423bb774612f0e8eaabfd9501d03389ff2cdbd.1697779681.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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 22:33:13 -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 3270d56b5c37..3d4e8edaa10b 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -162,7 +162,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