Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1186407pxb; Sat, 16 Apr 2022 00:46:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF//lh7AbVhPrDIqZj5Z1evaXhYlrzeTgZ6Bo8ZNmoecor7SQtG6O1iyuVWPVy9Rs9gDf8 X-Received: by 2002:a05:6a00:1943:b0:4cb:79c9:fa48 with SMTP id s3-20020a056a00194300b004cb79c9fa48mr2445881pfk.47.1650095189924; Sat, 16 Apr 2022 00:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650095189; cv=none; d=google.com; s=arc-20160816; b=SoWqIA/6wfIsy7N7BEWnQNW7DIKZYjRBiy13Lug/UBZo0VvSqRvPOH89ZklsKomgc5 r+3jtsbU8ucWoCpQlBNwTSQFmqVWbqJliwiCvrfVS5XWwId5OoDyjqg33jSlg3bpf9BH /4OuqI0rCj4tM3AnpuNFGEyvOwLDscEbSQ0MsPBmIuArH9jgDi5ufPiSXTFaizbuG86o pUsbPOem9YztXEwn040sk0ndy2d3YlbDI8f1vYyCKqdZ2sCwpkQ7wh+QZOpS2AXMQli6 +aQKwcOwXtFDKBAb5pQNGqRRAw1bUjvCeRvRpdU95FfArFo4zOwnm5KNDvECqlJSCe1L 1J0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=kPBWSL9to4K9zYiZS2khBvfUT8+KwST/9E5bI1tkFWY=; b=clm7PQXE5uU5XGfbQTOMlcDT5Zb59LDIKv5EbqDmSTxKkasGrCJ4dUa2kUwSKrnrG0 2L5cZhhj3Aq1LG3Ap0nqfygSsD16sPznE3myMPBUjuVIEZRrPhx/+GGOF3DlJF0OSL1s vsbdgtqrLKmX7hwtla2r5cf+xqM+XWlsnoaT2IrarYDL0P6DzxepVQsepN1wJgigZVp+ qoFD5+tdK4nyi2AVgw3UsPhh/MWYA0gHyeYcAOLJEBtdN7Ehr+0o72m/d+8vpiZeapnW sNb+zDbTinEdls2FSWAjvEwu+pIeQaX3rObDXYp1u4tOOgTMKBAvV/7WuvgXeoLOi4pN Lr8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pDlHmmsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a170903410100b001544c952660si2890610pld.353.2022.04.16.00.46.15; Sat, 16 Apr 2022 00:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pDlHmmsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbiDPHgF (ORCPT + 99 others); Sat, 16 Apr 2022 03:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiDPHgF (ORCPT ); Sat, 16 Apr 2022 03:36:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD55B3DD4; Sat, 16 Apr 2022 00:33:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EF569B8125F; Sat, 16 Apr 2022 07:33:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1743C385A3; Sat, 16 Apr 2022 07:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650094409; bh=jIbE4W95Z91IGJhTUxo9IvdkEdg4KANutS7Vlis0L+M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pDlHmmsg7ZttAvWqKPwWSiYS0sTQfbtAKlztE+vjMebQPTwlMDY7jfUNVUMD9s+lA snC4h3fqXVYVmrfzFbmXE3eOA4hnRIlgi7mAl5IgKd/DVrIuBb7ozDTUYbH6kGknI+ 5KGUUGJWZ0u9bVR1Vj9AeyEK6t76UMmJuY2gXEcu8X5CbLeT2pyst6qsguD/yFhkSR f7Z+g8Pu9BUyXBF60CnwwBHS99ImN66aU2VpjKQ/sx0a7TF9Vi4ZmZidABUzZgEcSW 7c3TbtQe0LUIW6PkCXhav5FtwHnverlQu9y+4PoV0aY7/X3CKDF3v+q7yp6o2MkhNg UOF51hPmy7WNQ== Date: Sat, 16 Apr 2022 09:33:20 +0200 From: Jakub Kicinski To: Peilin Ye Cc: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Peilin Ye , Cong Wang , Feng Zhou , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net 2/2] ip6_gre: Fix skb_under_panic in __gre6_xmit() Message-ID: <20220416093320.13f4ba1d@kernel.org> In-Reply-To: <20220416065633.GA10882@bytedance> References: <9cd9ca4ac2c19be288cb8734a86eb30e4d9e2050.1649715555.git.peilin.ye@bytedance.com> <20220414131424.744aa842@kernel.org> <20220414200854.GA2729@bytedance> <20220415191133.0597a79a@kernel.org> <20220416065633.GA10882@bytedance> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Apr 2022 23:56:33 -0700 Peilin Ye wrote: > On Fri, Apr 15, 2022 at 07:11:33PM +0200, Jakub Kicinski wrote: > > > Could you explain this a bit more? It seems that commit 77a5196a804e > > > ("gre: add sequence number for collect md mode.") added this > > > intentionally. > > > > Interesting. Maybe a better way of dealing with the problem would be > > rejecting SEQ if it's not set on the device itself. > > According to ip-link(8), the 'external' option is mutually exclusive > with the '[o]seq' option. In other words, a collect_md mode IP6GRETAP > device should always have the TUNNEL_SEQ flag off in its > 'tunnel->parms.o_flags'. > > (However, I just tried: > > $ ip link add dev ip6gretap11 type ip6gretap oseq external > ^^^^ ^^^^^^^^ > ...and my 'ip' executed it with no error. I will take a closer look at > iproute2 later; maybe it's undefined behavior...) > > How about: > > 1. If 'external', then 'oseq' means "always turn off NETIF_F_LLTX, so > it's okay to set TUNNEL_SEQ in e.g. eBPF"; > > 2. Otherwise, if 'external' but NOT 'oseq', then whenever we see a > TUNNEL_SEQ in skb's tunnel info, we do something like WARN_ONCE() then > return -EINVAL. Maybe pr_warn_once(), no need for a stacktrace. > > When the device is set up without the SEQ bit enabled it disables Tx > > locking (look for LLTX). This means that multiple CPUs can try to do > > the tunnel->o_seqno++ in parallel. Not catastrophic but racy for sure. > > Thanks for the explanation! At first glance, I was wondering why don't > we make 'o_seqno' atomic until I found commit b790e01aee74 ("ip_gre: > lockless xmit"). I quote: > > """ > Even using an atomic_t o_seq, we would increase chance for packets being > out of order at receiver. > """ > > I don't fully understand this out-of-order yet, but it seems that making > 'o_seqno' atomic is not an option? atomic_t would also work (if it has enough bits). Whatever is simplest TBH. It's just about correctness, I don't think seq is widely used. Thanks!