Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5158554rwb; Wed, 17 Aug 2022 12:08:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6zDONMm89CU/N/djFOiWokC+CQZX+ED0Mk2VFV2wChyHWwEeeF4/RCbLpEmInWjWtBXCfs X-Received: by 2002:a05:6402:438d:b0:43d:b383:660f with SMTP id o13-20020a056402438d00b0043db383660fmr24124527edc.283.1660763291691; Wed, 17 Aug 2022 12:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660763291; cv=none; d=google.com; s=arc-20160816; b=Jalu4ITLYwOZWfv4hk1ud6SKIjpngorLNQPEA5CcVutXSdiUizW4R5igC4S4U29qy4 rxoaZZNOE32FrcTVmZlFVssZUZRO2F+sCXjNnEdLiG2i0FKbi4YGCcgVkG8Z6GhrDie7 jLm3QC7/fhpye9UHzmsQGmXSDcv9liaxP3FM+jRmTVKyZjz49CmZ2aGWNYyf4QFTfKSH 7Gj4sN/4n0XzatqIxOxiuEUeo7GenE5X7bSIVl7fDftPpBfqMI4oT5ORuLz0EsNk2ys+ WvvjWsZKJ9YSlY+zFS1WDKbgdsk06BIgS3WK/RfKDLtscKO1l9ldCIZrL2RwvtNUVpYA 1Ulw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=i5SFoQcq3PCCNAwnmZYc6QgGe4ba2fR6mdX4aXQzHiI=; b=RsQihW8FnfTVbbogzrTFBk7cSZoRrBq/357brPSAuFZlpA5uAa4tJ21B69shcT2oSV vxMvlxeIWa1p1tNy8+F2xncbmT13SKQmoNjVGnmXnv0NrOtGPxfZA/RRv2Q0aJPX1mVP Rselg+LoLCty5A70Isr5IwVxAxYCCwPgzRXjgFV98Nkc3mfCx7NE8fcBcF8lvcT5zlyw 6UVXDJxVbD+1uKptyi/Yfii8xz/YZCXeSLSCNq/VpEGLSRag/p9hBqjMy61QGzmsyxZa nXirv5u21fs2d2g0AdEueFE3sxnE64Vu6e8ULBSNSIRb9VU2l0NLm4DnpkTN8KEbX7ls tOCw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb5-20020a0564020d0500b0043ab664c9e7si15103277edb.282.2022.08.17.12.07.43; Wed, 17 Aug 2022 12:08:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236670AbiHQSfF (ORCPT + 99 others); Wed, 17 Aug 2022 14:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237097AbiHQSfD (ORCPT ); Wed, 17 Aug 2022 14:35:03 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F0B9C1D0; Wed, 17 Aug 2022 11:35:01 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1oONsT-0001oq-Rk; Wed, 17 Aug 2022 20:34:53 +0200 Date: Wed, 17 Aug 2022 20:34:53 +0200 From: Florian Westphal To: Daniel Xu Cc: Florian Westphal , Toke =?iso-8859-15?Q?H=F8iland-J=F8rgensen?= , "bpf@vger.kernel.org" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Kumar Kartikeya Dwivedi , pablo@netfilter.org, netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 2/3] bpf: Add support for writing to nf_conn:mark Message-ID: <20220817183453.GA24008@breakpoint.cc> References: <871qth87r1.fsf@toke.dk> <20220815224011.GA9821@breakpoint.cc> <5c7ac2ab-942f-4ee7-8a9c-39948a40681c@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5c7ac2ab-942f-4ee7-8a9c-39948a40681c@www.fastmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,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 Daniel Xu wrote: > On Mon, Aug 15, 2022, at 4:40 PM, Florian Westphal wrote: > > Toke H?iland-J?rgensen wrote: > >> > Support direct writes to nf_conn:mark from TC and XDP prog types. This > >> > is useful when applications want to store per-connection metadata. This > >> > is also particularly useful for applications that run both bpf and > >> > iptables/nftables because the latter can trivially access this metadata. > >> > > >> > One example use case would be if a bpf prog is responsible for advanced > >> > packet classification and iptables/nftables is later used for routing > >> > due to pre-existing/legacy code. > >> > > >> > Signed-off-by: Daniel Xu > >> > >> Didn't we agree the last time around that all field access should be > >> using helper kfuncs instead of allowing direct writes to struct nf_conn? > > > > I don't see why ct->mark needs special handling. > > > > It might be possible we need to change accesses on nf/tc side to use > > READ/WRITE_ONCE though. > > I reviewed some of the LKMM literature and I would concur that > READ/WRITE_ONCE() is necessary. Especially after this patchset. > > However, it's unclear to me if this is a latent issue. IOW: is reading > ct->mark protected by a lock? I only briefly looked but it doesn't > seem like it. No, its not protected by a lock. READ/WRITE_ONCE is unrelated to your patchset, this is a pre-existing "bug".