Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5044149rdb; Tue, 12 Dec 2023 18:06:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEShMFb5Yeiag2atnZzPqQLBMCzMB3EasxEGqriGo4SJBea0b1S+qVyPnJ9WrmgV4o4NO/ X-Received: by 2002:a05:6830:200e:b0:6d9:eff7:e153 with SMTP id e14-20020a056830200e00b006d9eff7e153mr7303829otp.47.1702433184796; Tue, 12 Dec 2023 18:06:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702433184; cv=none; d=google.com; s=arc-20160816; b=c/g5jxhWhIZfOS557Wodo4T4BFV2uh15nYWwYZnfay/BShA+8d2Ee2w1k8APmLrjVk rIrWzSHaua7kRyZvlEmFEdivgIp+t+VDy45H17aEc9wAORfdCYeoFVZ0IecW7EAWa7ut 6LglKOuDPJD6aw4IYqqx9XHD3ITXsFKgDeF9H3tcnysNLwBbLdqqa4skUkPeK+1H/NYr vqQw6VhtzMoILA6l98ee0kCPyIXQ57wGAWOhQvfVg6jaMR//6P8Yv2od4CHj/b1VeDh2 Z9TTfusdlVS/d3Ep56C7aLKgk6c1IWDuM2d8qHvFVnK9XFQ3iR+gpuR6j72lu7ZNzGpY 0sxQ== 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=Wre/byWt1ayktHNpAoL/v4hhza7PbfuLtf7/RBkwTuo=; fh=yOMeXmdwDm6CHXvtJXmaZBu9ULA40v2mfcvPTvbQZyY=; b=vodZQMiEYERwvyU+tUY3HQI570gyJzkMzPIKIKlrsDeGLzLvvh3adVeor+UcjZW97w Ss70KUYwRaqZTUOsp6BV36Jy9dBdXQHbKMEWzhNZOIDciHOT4V1Ytl5b6gUHAjIVvzXX nJjF+HQh7HWkWmZT7X/8/jAPsl8YykgY1BrpEE43E/BBD08JZ1f5mUmtp6GWkUl01Ylh /StHOgVaVbtn1bsjM7d+FEoMsWH5OUyTyw/SGuAEAahVOF6WDEkcgqoR+/9DY5tZVUOI WJWwDFqL+YYKfqom+/UKMNBzkchSlYc61x41koNo/IkvBdK9eX60Ud33LOwU0ryR05Nq GkhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YmBq69xj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b8-20020a6541c8000000b005c626072edfsi8428947pgq.773.2023.12.12.18.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 18:06:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YmBq69xj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 18940801B392; Tue, 12 Dec 2023 18:06:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378199AbjLMCF6 (ORCPT + 99 others); Tue, 12 Dec 2023 21:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232721AbjLMCF5 (ORCPT ); Tue, 12 Dec 2023 21:05:57 -0500 Received: from mail-yw1-x1144.google.com (mail-yw1-x1144.google.com [IPv6:2607:f8b0:4864:20::1144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A6EAA; Tue, 12 Dec 2023 18:06:03 -0800 (PST) Received: by mail-yw1-x1144.google.com with SMTP id 00721157ae682-5c85e8fdd2dso62557197b3.2; Tue, 12 Dec 2023 18:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702433163; x=1703037963; 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=Wre/byWt1ayktHNpAoL/v4hhza7PbfuLtf7/RBkwTuo=; b=YmBq69xjH2lvuyEz+yQQE9kEm8QH9zF11jrqLCDfX+UmJbFmtaRFzjluHfN6deHtx2 gizrhMCGlOFExCzNRacGtaxV4PsIat3otgh5lN0YymLmw7nlxl82c+FV3NAZpmt897bQ NmNJSC2+tmxKQzvPjBn/E4HLFaQlZ/hBkVoj0sqUKSKD0QDnpld5exqWBzPlKlTsCQHe WyjmfMBf3u8rrZp7NkSIOxs4dcBYLXNWQRmxf++TOrxZRLr52c6Sp+hZaLicccDfefFV TlbGvy8XdJf3mRIOinWRPJfV/RQa2yWn0BEdqgCv4vNZQaiIR1DxEln19ZR/f8vnMmG3 0DRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702433163; x=1703037963; 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=Wre/byWt1ayktHNpAoL/v4hhza7PbfuLtf7/RBkwTuo=; b=qDpq/6jI8D7krQeg904Q+gjP2p64O+z9RMivOqcH+bHaLfaAM//MOlPWnnoCV5joKF 2Apslmd6sOmjI56bDCD37XgEw7e2CTjNiEdRJ/KjhRtqcllwh8gN2pUw1SuvmwB3NwsV JLoisBVXFVJNt7gOnKwNZLO9knvhQADM4h9yOsP11Imjs+cawxfr8XcyJZrtUlfFn6lW 8f+ZTLVMwwG81hutwNuQQS+8X7CzNzocbizUyHLToFvM8nhba7mJjdEJ3FadUFq/BuQ5 H5gYFRhmYWhv79YUoFZtOz0QIg3Sz9XyUg/zJDi011OXFmH8ICmtFtaEKUYmMKOwW2gR iKLw== X-Gm-Message-State: AOJu0Ywb3LhBJPokgSFtY344jj1IU9yvBm8MaG+uOOEbD8CExfubAslj lhbyq1QX3/5s2qUW3Pq0ZMJRNV7qqfGzCy2YQOQ= X-Received: by 2002:a5b:d44:0:b0:dbc:cc94:1dd7 with SMTP id f4-20020a5b0d44000000b00dbccc941dd7mr389999ybr.56.1702433162899; Tue, 12 Dec 2023 18:06:02 -0800 (PST) MIME-Version: 1.0 References: <20231212131031.3088661-1-menglong8.dong@gmail.com> In-Reply-To: From: Menglong Dong Date: Wed, 13 Dec 2023 10:05:51 +0800 Message-ID: Subject: Re: [PATCH net-next v2 0/2] bpf: support to trace BPF_JNE To: Andrii Nakryiko 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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 18:06:19 -0800 (PST) On Wed, Dec 13, 2023 at 8:00=E2=80=AFAM Andrii Nakryiko wrote: > > 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 caus= e > > 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".= In 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! > Opps, sorry that I offered a wrong tag......:/ > 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. > Yeah, sounds better. > Oh, and just to keep feedback in one place. In patch #2 you have a > typo in the subject "not qeual" -> "not equal". Ok, I'll fix it in the next version. Thanks! Menglong Dong