From: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
To: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Cc: Xu Kuohai <xukuohai@huaweicloud.com>,
Eduard Zingerman <eddyz87@gmail.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
Roberto Sassu <roberto.sassu@huawei.com>,
Edward Cree <ecree.xilinx@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Santosh Nagarakatte <santosh.nagarakatte@rutgers.edu>,
Srinivas Narayana <srinivas.narayana@rutgers.edu>,
Matan Shachnai <m.shachnai@rutgers.edu>
Subject: Re: [RFC bpf-next] bpf, verifier: improve signed ranges inference for BPF_AND
Date: Fri, 2 Aug 2024 17:30:21 -0400 [thread overview]
Message-ID: <CAM=Ch06FP+emu3s_2_XNVm1CPfBkf_Ei-xuJgsN=DWM7FFEtxA@mail.gmail.com> (raw)
In-Reply-To: <xhc5uslwucbu4233iqszgsj3q4bsu2xtjtrh5qmosqlm72uq52@mhwul4hzgd3p>
On Tue, Jul 30, 2024 at 12:26 AM Shung-Hsi Yu <shung-hsi.yu@suse.com> wrote:
[...]
> That is great to hear and really boost the level of confidence. Though I
> did made an update[1] to the patch such that implementation of
> negative_bit_floor() is change from
>
> v &= v >> 1;
> v &= v >> 2;
> v &= v >> 4;
> v &= v >> 8;
> v &= v >> 16;
> v &= v >> 32;
> return v;
>
> to one that closer resembles tnum_range()
>
> u8 bits = fls64(~v); /* find most-significant unset bit */
> u64 delta;
>
> /* special case, needed because 1ULL << 64 is undefined */
> if (bits > 63)
> return 0;
>
> delta = (1ULL << bits) - 1;
> return ~delta;
>
This [1] is indeed the version of the patch that we checked: the one that
uses fls and fls64 in negative_bit_floor and negative32_bit_floor .
I replied here because you had CCed us in this thread.
Note that for checking in Agni, the implementation of fls and fls64 were
borrowed from asm-generic [2,3,4].
Having said that, the patch [1] looks good to me.
Tested-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
[1]: https://lore.kernel.org/bpf/20240719081702.137173-1-shung-hsi.yu@suse.com/
[2]: https://elixir.bootlin.com/linux/v6.10/source/include/asm-generic/bitops/fls.h#L43
[3]: https://elixir.bootlin.com/linux/v6.10/source/include/asm-generic/bitops/fls64.h#L19
[4]: https://elixir.bootlin.com/linux/v6.10/source/include/asm-generic/bitops/__fls.h#L45
next prev parent reply other threads:[~2024-08-02 21:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 11:38 [PATCH bpf-next v4 13/20] bpf, lsm: Add check for BPF LSM return value Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 14/20] bpf: Prevent tail call between progs attached to different hooks Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 15/20] bpf: Fix compare error in function retval_range_within Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 16/20] bpf: Add a special case for bitwise AND on range [-1, 0] Xu Kuohai
2024-07-15 15:29 ` Shung-Hsi Yu
2024-07-16 7:05 ` Xu Kuohai
2024-07-16 14:52 ` [RFC bpf-next] bpf, verifier: improve signed ranges inference for BPF_AND Shung-Hsi Yu
2024-07-16 15:10 ` Shung-Hsi Yu
2024-07-17 21:10 ` Eduard Zingerman
2024-07-19 8:32 ` Shung-Hsi Yu
2024-07-28 22:38 ` Harishankar Vishwanathan
2024-07-30 4:25 ` Shung-Hsi Yu
2024-08-02 21:30 ` Harishankar Vishwanathan [this message]
2024-07-16 15:19 ` [PATCH bpf-next v4 16/20] bpf: Add a special case for bitwise AND on range [-1, 0] Shung-Hsi Yu
2024-07-11 11:38 ` [PATCH bpf-next v4 17/20] selftests/bpf: Avoid load failure for token_lsm.c Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 18/20] selftests/bpf: Add return value checks for failed tests Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 19/20] selftests/bpf: Add test for lsm tail call Xu Kuohai
2024-07-11 11:38 ` [PATCH bpf-next v4 20/20] selftests/bpf: Add verifier tests for bpf lsm Xu Kuohai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM=Ch06FP+emu3s_2_XNVm1CPfBkf_Ei-xuJgsN=DWM7FFEtxA@mail.gmail.com' \
--to=harishankar.vishwanathan@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ecree.xilinx@gmail.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=m.shachnai@rutgers.edu \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=santosh.nagarakatte@rutgers.edu \
--cc=sdf@google.com \
--cc=shung-hsi.yu@suse.com \
--cc=song@kernel.org \
--cc=srinivas.narayana@rutgers.edu \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).