BPF List
 help / color / mirror / Atom feed
From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	martin.lau@kernel.org, kernel-team@meta.com,
	Eduard Zingerman <eddyz87@gmail.com>
Subject: Re: [PATCH v2 bpf-next 05/10] bpf: enforce precise retval range on program exit
Date: Thu, 30 Nov 2023 13:29:33 +0800	[thread overview]
Message-ID: <ZWgdvcz4ZIc3KNVG@u94a> (raw)
In-Reply-To: <CAEf4BzZyHd80b3WEJLrBfim4oZ6t7pVMYhk_oznPg63a-r-P_Q@mail.gmail.com>

On Wed, Nov 29, 2023 at 08:23:41AM -0800, Andrii Nakryiko wrote:
> On Wed, Nov 29, 2023 at 3:24 AM Shung-Hsi Yu <shung-hsi.yu@suse.com> wrote:
> >
> > On Tue, Nov 28, 2023 at 04:36:15PM -0800, Andrii Nakryiko wrote:
> > > Similarly to subprog/callback logic, enforce return value of BPF program
> > > using more precise umin/umax range.
> > >
> > > We need to adjust a bunch of tests due to a changed format of an error
> > > message.
> > >
> > > Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> >
> > ...
> >
> > Q: should the missing register name and values be added?
> 
> Probably not, it makes future refactoring a bit less painful. If the
> important part is to check that there *was* a message about invalid
> return result, rather *what exact format* of that message was, then
> matching for a substring is enough and makes the test a bit more
> robust to future slight refactorings.
> 
> > I know relatively little about selftest, but scrolling through it looks
> > as though the expect verifier message is incomplete. (Admittedly lots of
> > them are like this even before this patch, and this patch improves the
> > situation already)
> 
> Often times it's actually a mistake to expect exact format, it makes
> for painful refactoring and improvements. I feel it every time I touch
> verifier log formatting logic :( So I don't want to add to that pain.

Understood. Thanks for going through the reasoning!

> > e.g.
> >
> > > --- a/tools/testing/selftests/bpf/progs/test_global_func15.c
> > > +++ b/tools/testing/selftests/bpf/progs/test_global_func15.c
> > > @@ -13,7 +13,7 @@ __noinline int foo(unsigned int *v)
> > >  }
> > >
> > >  SEC("cgroup_skb/ingress")
> > > -__failure __msg("At program exit the register R0 has value")
> > > +__failure __msg("At program exit the register R0 has ")
> > >  int global_func15(struct __sk_buff *skb)
> > >  {
> > >       unsigned int v = 1;
> >
> > looks like it is missing umin/umax=1
> >
> > ...
> >
> > > diff --git a/tools/testing/selftests/bpf/progs/verifier_cgroup_inv_retcode.c b/tools/testing/selftests/bpf/progs/verifier_cgroup_inv_retcode.c
> > > index d6c4a7f3f790..4655f01b24aa 100644
> > > --- a/tools/testing/selftests/bpf/progs/verifier_cgroup_inv_retcode.c
> > > +++ b/tools/testing/selftests/bpf/progs/verifier_cgroup_inv_retcode.c
> > > @@ -7,7 +7,7 @@
> > >
> > >  SEC("cgroup/sock")
> > >  __description("bpf_exit with invalid return code. test1")
> > > -__failure __msg("R0 has value (0x0; 0xffffffff)")
> > > +__failure __msg("umax=4294967295 should have been in [0, 1]")
> > >  __naked void with_invalid_return_code_test1(void)
> > >  {
> > >       asm volatile ("                                 \
> >
> > looks like it is missing mention of R0, etc.

  reply	other threads:[~2023-11-30  5:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  0:36 [PATCH v2 bpf-next 00/10] BPF verifier retval logic fixes Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 01/10] bpf: provide correct register name for exception callback retval check Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 02/10] bpf: enforce precision of R0 on callback return Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 03/10] bpf: enforce exact retval range on subprog/callback exit Andrii Nakryiko
2023-11-29  3:40   ` Andrii Nakryiko
2023-11-29 10:55   ` Shung-Hsi Yu
2023-11-29 16:23     ` Andrii Nakryiko
2023-11-30  5:23       ` Shung-Hsi Yu
2023-11-30  6:41         ` Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 04/10] selftests/bpf: add selftest validating callback result is enforced Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 05/10] bpf: enforce precise retval range on program exit Andrii Nakryiko
2023-11-29 11:23   ` Shung-Hsi Yu
2023-11-29 16:23     ` Andrii Nakryiko
2023-11-30  5:29       ` Shung-Hsi Yu [this message]
2023-11-29  0:36 ` [PATCH v2 bpf-next 06/10] bpf: unify async callback and program retval checks Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 07/10] bpf: enforce precision of R0 on program/async callback return Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 08/10] selftests/bpf: validate async callback return value check correctness Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 09/10] selftests/bpf: adjust global_func15 test to validate prog exit precision Andrii Nakryiko
2023-11-29  0:36 ` [PATCH v2 bpf-next 10/10] bpf: simplify tnum output if a fully known constant Andrii Nakryiko
2023-11-29 11:27 ` [PATCH v2 bpf-next 00/10] BPF verifier retval logic fixes Shung-Hsi Yu
2023-11-29 16:23   ` Andrii Nakryiko

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=ZWgdvcz4ZIc3KNVG@u94a \
    --to=shung-hsi.yu@suse.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /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