[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b3b620d04fc3bcf4286dc4bb8c6fd995df86a25.camel@gmail.com>
Date: Wed, 18 Jun 2025 14:22:27 -0700
From: Eduard Zingerman <eddyz87@...il.com>
To: Harishankar Vishwanathan <harishankar.vishwanathan@...il.com>,
ast@...nel.org
Cc: m.shachnai@...gers.edu, srinivas.narayana@...gers.edu,
santosh.nagarakatte@...gers.edu, Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>, Andrii Nakryiko
<andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu
<song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, KP Singh
<kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo
<haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko
<mykolal@...com>, Shuah Khan <shuah@...nel.org>, Matan Shachnai
<m.shachnai@...il.com>, Luis Gerhorst <luis.gerhorst@....de>, Kumar
Kartikeya Dwivedi <memxor@...il.com>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v2 2/2] selftests/bpf: Add testcases for BPF_ADD and
BPF_SUB
On Tue, 2025-06-17 at 19:17 -0400, Harishankar Vishwanathan wrote:
> The previous commit improves the precision in scalar(32)_min_max_add,
> and scalar(32)_min_max_sub. The improvement in precision occurs in
> cases when all outcomes overflow or underflow, respectively. This
> commit adds selftests that exercise those cases.
>
> Co-developed-by: Matan Shachnai <m.shachnai@...gers.edu>
> Signed-off-by: Matan Shachnai <m.shachnai@...gers.edu>
> Signed-off-by: Harishankar Vishwanathan <harishankar.vishwanathan@...il.com>
> ---
Could you please also add test cases when one bound overflows while
another does not? Or these are covered by some other tests?
[...]
> +SEC("socket")
> +__description("64-bit addition overflow, all outcomes overflow")
> +__success __log_level(2)
> +__msg("7: (0f) r5 += r3 {{.*}} R5_w=scalar(smin=0x800003d67e960f7d,umin=0x551ee3d67e960f7d,umax=0xc0149fffffffffff,smin32=0xfe960f7d,umin32=0x7e960f7d,var_off=(0x3d67e960f7d; 0xfffffc298169f082))")
Would it be possible to pick some more "human readable" constants here?
As-is it is hard to make sense what verifier actually computes.
> +__retval(0)
> +__naked void add64_ovf(void)
> +{
> + asm volatile (
> + "call %[bpf_get_prandom_u32];"
> + "r3 = r0;"
> + "r4 = 0x950a43d67e960f7d ll;"
> + "r3 |= r4;"
> + "r5 = 0xc014a00000000000 ll;"
> + "r5 += r3;"
> + "r0 = 0;"
> + "exit"
> + :
> + : __imm(bpf_get_prandom_u32)
> + : __clobber_all);
> +}
[...]
Powered by blists - more mailing lists