Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1408462rdb; Fri, 1 Dec 2023 16:12:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8LOxUvHMFPkFkBxHSIP33ohqWDh7k5jhtLYZKoEdSukmSfZfdJCEds5zIT871Gg23oUtH X-Received: by 2002:a05:6a21:1aa:b0:18f:97c:6149 with SMTP id le42-20020a056a2101aa00b0018f097c6149mr530133pzb.70.1701475935194; Fri, 01 Dec 2023 16:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701475935; cv=none; d=google.com; s=arc-20160816; b=pv6qnP+Cx+XTVeg6HpYKGqH4Y9GwDM+YtNTUDS7P6L5dkMPjZFcs1SpekPxdKI2t6R utaaj9nQxuba4+EAYAgav3fajcWPG8E3T0450AqOwWQAhzT4wTKmOUO+n39jgIr3W1yy ZVETqVCGKPPLbXl1hyj/87Vp+cPr/r29dUyHemFURf4y+S1hGl6+zDRAXXMaVipRUgRg IcFwYUPPzhGgkFWnb5AyWiBesx9hzHcHThvQY997/hfbT8XFi9VDn4g6sP0DHvwtQOLQ lQNTmqeDMFzp02HwosJDlQqVeJTLyTnvAzX8fy9IgXhSQh7ywpR135B1xjsnG6SlWYHs DZrQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=YupG7R41Yytt8vtYDqX//EZ/J14h7fjiRvBhKo5wcQ0=; fh=vq8yzqUQ0CBt3E0sJDr5qcthOUW8VF9xrD4I8ocr5is=; b=isoOgyd/mXY523SECOkkfq3e78qsiBItsxdLVxlAjhSWHqrAf/2CsbgmcmmvIQzdm4 0bKTR8siWTzKTH03zEVfJQ83zeg7WtQ0xxfhNoN6qFYAyGb7W9zROR+5U7Q75lZlfLnj JfhtPGYN8pUqxYp7Kdq1WXOEy7K8vfQUhmLjXS0peE8KU15geBztMJQK2dbugyjPLhGo Aogu3OKdReO6xqmxwEThIcmly77aogJdiqkPGTDX0loDOcnt5kKV0U3Te8noWJMIkq/d BJgS/2iaWxYNkM61XCMI5gznfFhmIa5w7h19thdvrip6kaB35MM9KWVewM1vtoVsKXwr 2LJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fZaopnCG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=2Czlaiui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z27-20020a630a5b000000b005c1b2c911f0si4089629pgk.328.2023.12.01.16.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 16:12:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b=fZaopnCG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=2Czlaiui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BE87781DE390; Fri, 1 Dec 2023 16:12:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235382AbjLBAL5 (ORCPT + 99 others); Fri, 1 Dec 2023 19:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235386AbjLBALn (ORCPT ); Fri, 1 Dec 2023 19:11:43 -0500 Received: from new2-smtp.messagingengine.com (new2-smtp.messagingengine.com [66.111.4.224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61BA26B6; Fri, 1 Dec 2023 16:10:53 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 18A21580D31; Fri, 1 Dec 2023 19:10:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 01 Dec 2023 19:10:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1701475851; x=1701483051; bh=YupG7R41Yytt8vtYDqX//EZ/J14h7fjiRvB hKo5wcQ0=; b=fZaopnCGRFsBTf8Hf8AOl8dS/w0n3o4CUHSSJa0N2SSII79piEw ROinTnt/xawgSnY+5A63JsoYpZ5UgKW5rhtycmzuvUpZuIaVSunfX+gbRdJxTIcx ztPvFmJJT+Qajpbv0PtCNGfoW+YZh11Z4XKtd+Xkf3FwCNsvVtPOzT8Z9oHvdIa1 PW9shyOVV39b8Gq7ZbNpce38C3HBgYIFTLhc9/WIR/7Bh3Jt4IlwvSsSiwAXQCFS W293uqB3Jy2OSurPVh3FUypdxO4L2t/JtpTxOZMaDIlXRgjaf99WrH0fvhRlL/yF Ln7a4rEe3fw96DwBWDuYAwxxscZSqK2aYbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1701475851; x=1701483051; bh=YupG7R41Yytt8vtYDqX//EZ/J14h7fjiRvB hKo5wcQ0=; b=2CzlaiuiLR0lkj3BUwP/uUloOpxFEtS91d/oX9A/dpFzNYWY0FB zfwQcvIh4srIpIhsT1Z9YF3IGCpD/OUrWThtUFlDWLv40NRbdqaZGcMtqnIosCLl QoH2Lr4mIMrl5Tjx/ym72sJPBJ0JFLjyzI7hFizgF9Euwt5M5TQ7KVIAgJwYR72v s1R5DJbnvwLCUS3Or5hRuscL88TlLWTAn65sYe/tmxXXxDXtI98uc7tnJPkYJP3E WdZFpYUfDzXIkDGO7f4RRApT7K8ZCZ+kFKs3zMh9ZhrsJhDERRxaKvhOyb4iYLlI uRbL46vGkHjz0Srigbb99GeGsYZ5p1o2FcQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudejtddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvvefukfhfgggtugfgjgestheksfdt tddtjeenucfhrhhomhepffgrnhhivghlucgiuhcuoegugihusegugihuuhhurdighiiiqe enucggtffrrghtthgvrhhnpedtgfeuueeukeeikefgieeukeffleetkeekkeeggeffvedt vdejueehueeuleefteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Dec 2023 19:10:49 -0500 (EST) Date: Fri, 1 Dec 2023 17:10:47 -0700 From: Daniel Xu To: Andrii Nakryiko Cc: ast@kernel.org, daniel@iogearbox.net, shuah@kernel.org, andrii@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com, yonghong.song@linux.dev, eddyz87@gmail.com, mykolal@fb.com, martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: Re: [PATCH ipsec-next v3 5/9] libbpf: selftests: Add verifier tests for CO-RE bitfield writes Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 16:12:12 -0800 (PST) Hi Andrii, On Fri, Dec 01, 2023 at 03:52:25PM -0800, Andrii Nakryiko wrote: > On Fri, Dec 1, 2023 at 12:24 PM Daniel Xu wrote: > > > > Add some tests that exercise BPF_CORE_WRITE_BITFIELD() macro. Since some > > non-trivial bit fiddling is going on, make sure various edge cases (such > > as adjacent bitfields and bitfields at the edge of structs) are > > exercised. > > > > Signed-off-by: Daniel Xu > > --- > > .../selftests/bpf/prog_tests/verifier.c | 2 + > > .../bpf/progs/verifier_bitfield_write.c | 100 ++++++++++++++++++ > > 2 files changed, 102 insertions(+) > > create mode 100644 tools/testing/selftests/bpf/progs/verifier_bitfield_write.c > > > > LGTM, but I'm not sure why we need all those __failure_unpriv, see > below. Regardless: > > Acked-by: Andrii Nakryiko > > > diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c > > index 5cfa7a6316b6..67b4948865a3 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/verifier.c > > +++ b/tools/testing/selftests/bpf/prog_tests/verifier.c > > @@ -6,6 +6,7 @@ > > #include "verifier_and.skel.h" > > #include "verifier_array_access.skel.h" > > #include "verifier_basic_stack.skel.h" > > +#include "verifier_bitfield_write.skel.h" > > #include "verifier_bounds.skel.h" > > #include "verifier_bounds_deduction.skel.h" > > #include "verifier_bounds_deduction_non_const.skel.h" > > @@ -115,6 +116,7 @@ static void run_tests_aux(const char *skel_name, > > > > void test_verifier_and(void) { RUN(verifier_and); } > > void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); } > > +void test_verifier_bitfield_write(void) { RUN(verifier_bitfield_write); } > > void test_verifier_bounds(void) { RUN(verifier_bounds); } > > void test_verifier_bounds_deduction(void) { RUN(verifier_bounds_deduction); } > > void test_verifier_bounds_deduction_non_const(void) { RUN(verifier_bounds_deduction_non_const); } > > diff --git a/tools/testing/selftests/bpf/progs/verifier_bitfield_write.c b/tools/testing/selftests/bpf/progs/verifier_bitfield_write.c > > new file mode 100644 > > index 000000000000..8fe355a19ba6 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/verifier_bitfield_write.c > > @@ -0,0 +1,100 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include > > +#include > > + > > +#include > > +#include > > + > > +#include "bpf_misc.h" > > + > > +struct core_reloc_bitfields { > > + /* unsigned bitfields */ > > + uint8_t ub1: 1; > > + uint8_t ub2: 2; > > + uint32_t ub7: 7; > > + /* signed bitfields */ > > + int8_t sb4: 4; > > + int32_t sb20: 20; > > + /* non-bitfields */ > > + uint32_t u32; > > + int32_t s32; > > +} __attribute__((preserve_access_index)); > > + > > +SEC("tc") > > +__description("single CO-RE bitfield roundtrip") > > +__btf_path("btf__core_reloc_bitfields.bpf.o") > > +__success __failure_unpriv > > do we want __failure_unpriv at all? Is this failure related to > *bitfield* logic at all? Oh, I pre-emptively added it. From the docs, I thought __failure_unpriv meant "don't try to load this as an unprivileged used cuz it'll fail". And since I used the tc hook, I figured it'd fail. Removing the annotation doesn't seem to do anything bad so I'll drop it for v4. [...] Thanks, Daniel