Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp272252rdb; Sat, 30 Sep 2023 04:09:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ6/m730C3VQE+KofrUBdIIoGUVlvl+7KR0n4aEpHqRKYsZ7bcA6C7JjRK7sOpe3ZO4O85 X-Received: by 2002:a17:90b:204:b0:267:a859:dfef with SMTP id fy4-20020a17090b020400b00267a859dfefmr5770886pjb.27.1696072172318; Sat, 30 Sep 2023 04:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696072172; cv=none; d=google.com; s=arc-20160816; b=Vb65DLS6t+tvn/WhjRbDb7VqA3zewRnwqQvLW1S8BS4LhqXOUJXLCI+qBl2eOyjsKi LXSxBWMrKiNOfelDmWZSUq1xa7sjYgJ+B9DZwQNLXg8J7vE/ObZpJDDw1YNYK/mQv5FJ 7pyGSNhjrpJUuMTcdhbGdDKECHN9XwC0r5MzKZi652LzO2cGlt9AP9BXBNfXuwdVBbT4 HwO7sSjfGpuloHcQzkRLMdHDKDa4Hc3dXXy5iAeJNCBHrjAo/P/1ck9PasRkf+39FSEL o3UeEMSkGEWvE0KSbXTrQYNaIOXgYaW56SVSSQaGNPnDd2Ek6CsEZGB764mySUjgl+Qe u8cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jxVIIlW2OG882nUMFlJZ5MkbNBtAnYLluo8cgsSadTk=; fh=8OtbM2bjhFIghOrxnS81sCgSAux2cDLfNgnF/6Y0Y+Q=; b=A6/zU12QgZj7JMTOp3GOQBhw8yCKEmQBA3w/y53tj4EI+kodgZsoZAKda/okf3bCTn BLJM1hZ+V0B86Pa9vWbVdxa86rN6HxfxXl49P+Ltv5/nb4qMHdetCugyfuH6jS/PBpiS 4M8oQJEuQktARe1M4n+MgXIw4QI/ZMcMPRAA+k8AGfhxUTq0BzhQDc7N+mkryIS+PwTh yM9sEvquN/Ny/oCY8hksQg2sC1VdR5bivkGH3EidvxAGyXB0dsf+0e2x4QP3lWz2KD0t 9Hqwd9RBhJTTLKEL/GB2e2+FdVMlxMkx7BtM2VlDutqE1KjqG9Zko32/CotmvYYL8cVl Bcqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id x8-20020a17090a46c800b00276bf69ac44si3301672pjg.5.2023.09.30.04.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 04:09:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id EDDD68182DC8; Sat, 30 Sep 2023 04:09:29 -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 S234133AbjI3LJO (ORCPT + 99 others); Sat, 30 Sep 2023 07:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbjI3LJN (ORCPT ); Sat, 30 Sep 2023 07:09:13 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B670CA; Sat, 30 Sep 2023 04:09:10 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qmXqA-0003rY-Oh; Sat, 30 Sep 2023 13:08:54 +0200 Date: Sat, 30 Sep 2023 13:08:54 +0200 From: Florian Westphal To: Yan Zhai Cc: netdev@vger.kernel.org, "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: Re: [PATCH net] ipv6: avoid atomic fragment on GSO packets Message-ID: <20230930110854.GA13787@breakpoint.cc> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=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]); Sat, 30 Sep 2023 04:09:30 -0700 (PDT) Yan Zhai wrote: > 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); > + This helper is also called for skbs where IP6CB(skb)->frag_max_size exceeds the MTU, so this check looks wrong to me. Same remark for dst_allfrag() check in __ip6_finish_output(), after this patch, it would be ignored. I think you should consider to first refactor __ip6_finish_output to make the existing checks more readable (e.g. handle gso vs. non-gso in separate branches) and then add the check to last seg in ip6_finish_output_gso_slowpath_drop(). Alternatively you might be able to pass more info down to ip6_fragment and move decisions there. In any case we should make same frag-or-no-frag decisions, regardless of this being the orig skb or a segmented one,