Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp111238rdb; Fri, 29 Sep 2023 19:36:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6s3Z6NJLVsz+Pd/AXiB6GQad4svjbJyKTJYgtJW24mzV9xUumZJ3W+F6d4aTOxABquMaS X-Received: by 2002:a05:6a21:a5a8:b0:159:c07d:66f0 with SMTP id gd40-20020a056a21a5a800b00159c07d66f0mr9880100pzc.6.1696041381255; Fri, 29 Sep 2023 19:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696041381; cv=none; d=google.com; s=arc-20160816; b=GgBMMFmXyMd2sQQMU1l80W04EifsJERVNJi2oXnY1w594+C3qK7ZOrZfAorh7MwtZm gnh7A3rYFuoY3vEQalokSLt8iP4Hbk11b7nQTQ/Bu8LiF8W5sZZg1C1BKCCDkU2FTE2j eD9nhhQrVVUwc0XBXk1+UEAwJ5o87qOv4h+wv8gIMosOHrlwtbcwLMP+iWAzd/AcKvsj T60F6xDY9Us0sF3+wMQLuv3oPafp/y0NQGLYuhq0g9cSdCsYxySN42+ztlyi5yy6aSwp hQLdqWAXNi0Aq7vSyUxHoyX8Sn29ZzEQv/xi4H+sBfGQAiqzq1fa3FRyRW42+iQJ0+wY bFpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=72PAJei39nrMMwm0fE8A8KKvNqYVfjffekZbQ4no+DM=; fh=MDuofdc5W+PPcxJYxagxNQUn/DLEru4dXuOGWNjjbXQ=; b=yWXfwPJbrJQVYzzXOrDl4sP76LxXrbmgFPp4ffn1EKxJXc58MMqvtKTY/KfY06eUEp jhkhmEQm79636uQhPwy/a3YNfBEh/EZZiuJgNX1eBS6EzhPV6V6FNLCkAx/Ki2v8HTz7 CBAecb8ndmAWyAg9AwqQCUp4bVfcRzH7dpoMhzs24BX2EGqHqLwwpKrsyrzxknSqD1vv GHeKeGP6SzgsinXY89pka8DszrR3hSoMQ1hmW/RS3Z4CXXnXzeKmiHwmL/S9HRs9eBeE gesTlI9iYTvt/FdVT5kPqH21ROdeisWQO9suHOErA54aw+VFkxH/9JR1uA36eFbmE+by wYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=RzoNY289; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l9-20020a654c49000000b0055c7eb53d7fsi22361980pgr.584.2023.09.29.19.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 19:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=RzoNY289; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 513DD8096FDB; Fri, 29 Sep 2023 10:50:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233573AbjI2Rub (ORCPT + 99 others); Fri, 29 Sep 2023 13:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbjI2Ru0 (ORCPT ); Fri, 29 Sep 2023 13:50:26 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E67AC19F for ; Fri, 29 Sep 2023 10:50:23 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-65af726775eso4268156d6.0 for ; Fri, 29 Sep 2023 10:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1696009823; x=1696614623; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=72PAJei39nrMMwm0fE8A8KKvNqYVfjffekZbQ4no+DM=; b=RzoNY2897Fect+FfbNq1WDPmzGIvAyj+JzmEdxYdMRczO4VpoHulmIxE+T+UkMQDb4 klX4UzZq+/oMbQUqSzkpihiPMl9rLfvfnZAqC1ScIxnI0tfMPSzZgaBMUIwgh+gUNqp9 O0IUe+MeTEWY0lmA3WrLSdxl2uMFxtczVd+EXljsyZuPhC1S4hWEaTZ29En0IT3O/FOn aHuUaMyyziO1im2tPmVyEP+Uq/T2gU/isyetB8wuBca8HHMB74syUc6fYzBEW5dusf6N bgbK83veZOh5Cp+nfr0x6jSlMV/ES4ibVtApzbV7/s70bv91YdLviFFGDWDozt3ZH2Ya 59lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696009823; x=1696614623; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=72PAJei39nrMMwm0fE8A8KKvNqYVfjffekZbQ4no+DM=; b=AisJBdTvC9BnXqtv6kIazJNtXr2QuIiRNDF6sD9R3A0mguA72x00pbzIdl/rF0xdAi 83ebXxVc8VZqw/fQuwSU/fX+WFtiappQxI2SX0ijLrq0A96/xRzFDJSX8TGBW4hLgZWd zI3YkNjUOGwZ6YRjVWbgUsEYSqJs+cQmBagCnAQG/IMWd/YRf+KNmHs151ulzjcfor/R G1O/LK286CpNv8jWVXn3y9sXoEzl4UL2jT5bP7GO51kQENMdpVTf5nNhNb+XzZm8jaSJ F9P6iY9QCCIT5Tf6ERoEW005mewFNO198Oj6VOXkAg4mIdQAB6pHIbN1sYsWWkPmQSOS +2qQ== X-Gm-Message-State: AOJu0YwKubuEpD+sRR/dwBXxCwCg1t3qpifnZGSIE/ixZYcd9Z50igMM k4bRTVOV9ONW42LcErr+77aIFA== X-Received: by 2002:ad4:55cf:0:b0:65b:12b1:d54f with SMTP id bt15-20020ad455cf000000b0065b12b1d54fmr5656730qvb.22.1696009822937; Fri, 29 Sep 2023 10:50:22 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id p17-20020a0cf551000000b0065b1b5cd70csm3711634qvm.31.2023.09.29.10.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:50:22 -0700 (PDT) Date: Fri, 29 Sep 2023 10:50:20 -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 Subject: [PATCH net] ipv6: avoid atomic fragment on GSO packets Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 10:50:48 -0700 (PDT) GSO packets can contain a trailing segment that is smaller than gso_size. When examining the dst MTU for such packet, if its gso_size is too large, then all segments would be fragmented. However, there is a good chance the trailing segment has smaller actual size than both gso_size as well as the MTU, which leads to an "atomic fragment". RFC-8021 explicitly recommend to deprecate such use case. An Existing report from APNIC also shows that atomic fragments can be dropped unexpectedly along the path [1]. Add an extra check in ip6_fragment to catch all possible generation of atomic fragments. Skip atomic header if it is called on a packet no larger than MTU. 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 951ba8089b5b..42f5f68a6e24 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -854,6 +854,13 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, __be32 frag_id; u8 *prevhdr, nexthdr = 0; + /* RFC-8021 recommended atomic fragments to be deprecated. Double check + * the actual packet size before fragment it. + */ + mtu = ip6_skb_dst_mtu(skb); + if (unlikely(skb->len <= mtu)) + return output(net, sk, skb); + err = ip6_find_1stfragopt(skb, &prevhdr); if (err < 0) goto fail; @@ -861,7 +868,6 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, nexthdr = *prevhdr; nexthdr_offset = prevhdr - skb_network_header(skb); - mtu = ip6_skb_dst_mtu(skb); /* We must not fragment if the socket is set to force MTU discovery * or if the skb it not generated by a local socket. -- 2.30.2