Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4992777rdb; Tue, 12 Dec 2023 16:01:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyScE89wY3WUtLTaI2ebq4Oj5fhVdyV8cHk+VbuFlJJIGl1NEfqmaVXsL8q6chwcMbdhSB X-Received: by 2002:a05:6871:2b06:b0:1fa:e5ad:201a with SMTP id dr6-20020a0568712b0600b001fae5ad201amr9188876oac.18.1702425700218; Tue, 12 Dec 2023 16:01:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702425700; cv=none; d=google.com; s=arc-20160816; b=BbFTvGc1bPQIRh64k0CVn4RIkiJMclf4kqXMb4LzXg6mOw7h4cJ21XX/NwVxXaHmV6 xpaka3H7xc4DKSU7+0vn68xP2UEQ44jo94j1TWDbq8dlaybJW6TmT6+ptb6Pd7lGX/AT jhpCxs8nTsGRPOataGPEabcdBQd/56GZNT9FLtlWOK+F7gIsu27u5w8TKC2ek95UPv4Y gReS0BusH60Q9tOXHqfUx00DcuUz9+Ndy0IxjNaCpi0oFc+GHzkovQ7geq8Z1KJnjlji 5ZTmgyyEYCzUEB1iHHy8UVNAgi+QQH9KXKWKz8SsA+gmIk9a4b/EimtsREkYqThUvhj6 WSRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jaKGNb1VRd5VrDyxiTt9RbEg148bOMoqEkF4ucEMcYQ=; fh=6Vgz6156lByPIJS5YDG0X7R1ERjefNpe4D8YCqRpRm4=; b=PIdIo2P1gGSUUbiyrGVBlls+/vHybbxKPawQ/7K/VFujUYuPhez2KHgKJGFp84KrCd rAxsbXlluuFELF3gsn1g2cH5v7rb3RnbR+pNjErvEZorih63PXmPnwDfbonx4esHzRN6 BArk8WX6udBHVBPhJg8I3O84IUbDx3OJuCoJWHxE7m/P5VLyCpc0UpCdE7ex02h3NK/i FurkTzZzrEl9CTWc7cfj8kPp3+2bYP2OvK5fkyyfQbEH3+bM58JMcTX8iAy2hEoWeIGB qb6JgKQnAdOExQYGfY79K/XW7HrW2Ss8P2AbJoN2xgwqRjGQ0XGoKO2pZWwjjXiJ/VAv 3pjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S9ivD7ZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t12-20020a6564cc000000b005c66b15ec25si8181612pgv.824.2023.12.12.16.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:01:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S9ivD7ZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0B4218051627; Tue, 12 Dec 2023 16:01:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377631AbjLMAAt (ORCPT + 99 others); Tue, 12 Dec 2023 19:00:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377520AbjLMAAs (ORCPT ); Tue, 12 Dec 2023 19:00:48 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37612BE; Tue, 12 Dec 2023 16:00:52 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a1f6433bc1eso988639966b.1; Tue, 12 Dec 2023 16:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702425650; x=1703030450; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jaKGNb1VRd5VrDyxiTt9RbEg148bOMoqEkF4ucEMcYQ=; b=S9ivD7ZXIqANASyAZdAcw38OJxzPLwjVns1W12tepRBvx1QXzD1KBn5E4VPjIuy6a1 CgCDXiUjNnq9igmTIyQ6mWdBOdleK1Zt1H/rYbFMD52P4RuRWQ5zzCbExp1oNNONNBDG zVgJol/ddV51NZQVXLK+MGMVU1G1yypdZxSmj1jR5b4kh132RcPftwEsu8+gg8HEMgLA /YkBKucoCmjArSqps+dNSdg4IkOtwaCEBWeg4aKII8xaIgviSJ3e+9wJRv5ixqCC64dJ rYDQ8LU57Nc9h7hbpklLNik1e6DcjGk6VC/vXWOrNG5KemRWCpdB9kFdOnAwoDeGPhi/ 4mSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702425650; x=1703030450; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jaKGNb1VRd5VrDyxiTt9RbEg148bOMoqEkF4ucEMcYQ=; b=JBt+l9gmXpAFeQ5L2mxN6Tk8VNuOlut9RbG/OZ2qflkzKSqWQlgkxhdlP7PMfFJJXr UTqeLlpFa+wVeMJIB7YljMAiZ1PhtzWAxYFv2l4zj2ziSp+4JoaRwNYa87iIL0eu5wzf fnntVD3sXJJkHlUr3ZOJuMcYR+SxKPzwT5ZHzp3oRZst/WHPZVjSWtokEhpNKPkO4ye2 93wsL47f5QxWPiQ2rW/JpaES0fekEL+B7F3YBr6i7vZ3VGF/IJ8nUjcxNUDed/K0l4OT MIsU4Pra51q8MVhSCAe5/uKgICb9XDHiQZwFPrK1/gVm3yIgDLrmZuughBWaU+3tlABN oQAw== X-Gm-Message-State: AOJu0Yxp2jz+3EgK01gCjWOr86HQdra1Kj+eNgoeIvnInaiLr1Y6X49p vZOQzIwtE4ebE19KN3JMVA3vGIxW3QXJLL+P3s0EIA8rZdk= X-Received: by 2002:a17:906:101e:b0:a01:ae9a:c1d3 with SMTP id 30-20020a170906101e00b00a01ae9ac1d3mr7424415ejm.11.1702425650293; Tue, 12 Dec 2023 16:00:50 -0800 (PST) MIME-Version: 1.0 References: <20231212131031.3088661-1-menglong8.dong@gmail.com> In-Reply-To: <20231212131031.3088661-1-menglong8.dong@gmail.com> From: Andrii Nakryiko Date: Tue, 12 Dec 2023 16:00:38 -0800 Message-ID: Subject: Re: [PATCH net-next v2 0/2] bpf: support to trace BPF_JNE To: Menglong Dong Cc: andrii@kernel.org, yonghong.song@linux.dev, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, martin.lau@linux.dev, song@kernel.org, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 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]); Tue, 12 Dec 2023 16:01:25 -0800 (PST) On Tue, Dec 12, 2023 at 5:15=E2=80=AFAM Menglong Dong wrote: > > For now, the reg bounds is not handled for BPF_JNE case, which can cause > the failure of following case: > > /* The type of "a" is u16 */ > if (a > 0 && a < 100) { > /* the range of the register for a is [0, 99], not [1, 99], > * and will cause the following error: > * > * invalid zero-sized read > * > * as a can be 0. > */ > bpf_skb_store_bytes(skb, xx, xx, a, 0); > } > > In the code above, "a > 0" will be compiled to "jmp xxx if a =3D=3D 0". I= n the > TRUE branch, the dst_reg will be marked as known to 0. However, in the > fallthrough(FALSE) branch, the dst_reg will not be handled, which makes > the [min, max] for a is [0, 99], not [1, 99]. > > In the 1st patch, we reduce the range of the dst reg if the src reg is a > const and is exactly the edge of the dst reg For BPF_JNE. > > In the 2nd patch, we just activate the test case for this logic in > range_cond(), which is committed by Andrii in the > commit 8863238993e2 ("selftests/bpf: BPF register range bounds tester"). > > Changes since v1: > - simplify the code in the 1st patch > - introduce the 2nd patch for the testing > > Menglong Dong (2): > bpf: make the verifier trace the "not qeual" for regs > selftests/bpf: activate the OP_NE login in range_cond() > > kernel/bpf/verifier.c | 29 ++++++++++++++++++- > .../selftests/bpf/prog_tests/reg_bounds.c | 7 +---- > 2 files changed, 29 insertions(+), 7 deletions(-) > > -- > 2.39.2 > +1 to all the feedback from Eduard. Besides that, please target bpf-next tree (so, [PATH bpf-next] for subject prefix), thanks! Also, instead of "verifier traces", I think "verifier tracks" is less confusing wording. Tracing within the BPF ecosystem is usually used for a completely different meaning. Oh, and just to keep feedback in one place. In patch #2 you have a typo in the subject "not qeual" -> "not equal".