BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net,  martin.lau@linux.dev, kernel-team@fb.com,
	yonghong.song@linux.dev,  memxor@gmail.com, awerner32@gmail.com
Subject: Re: [PATCH bpf 03/12] selftests/bpf: fix bpf_loop_bench for new callback verification scheme
Date: Fri, 17 Nov 2023 20:52:41 +0200	[thread overview]
Message-ID: <a2e55bf0b299df0453789a79755c0c4369c5c046.camel@gmail.com> (raw)
In-Reply-To: <CAEf4Bza=+t8aS+mfaywe6ozkzYfo-DjH01qicfks4rsYCQs_Dw@mail.gmail.com>

On Fri, 2023-11-17 at 11:46 -0500, Andrii Nakryiko wrote:
[...]
> > This has dire implications for bpf_loop_bench:
> > 
> >     SEC("fentry/" SYS_PREFIX "sys_getpgid")
> >     int benchmark(void *ctx)
> >     {
> >             for (int i = 0; i < 1000; i++) {
> >                     bpf_loop(nr_loops, empty_callback, NULL, 0);
> >                     __sync_add_and_fetch(&hits, nr_loops);
> >             }
> >             return 0;
> >     }
> > 
> > W/o callbacks change for verifier it merely represents 1000 calls to
> > empty_callback(). However, with callbacks change things become
> > exponential:
> > - i=0: state exploring empty_callback is scheduled with i=0 (a);
> > - i=1: state exploring empty_callback is scheduled with i=1;
> >   ...
> > - i=999: state exploring empty_callback is scheduled with i=999;
> > - state (a) is popped from stack;
> > - i=1: state exploring empty_callback is scheduled with i=1;
> >   ...
> 
> would this still happen if you use an obfuscated zero initializer for i?
> 
> int zero = 0; /* global var */
> 
> ...
> 
> 
> for (i = zero; i < 1000; i++) {
>      ...
> }

In that case it fails with jump limit.
Mechanism for states explosion is similar, as far as I understand.



  reply	other threads:[~2023-11-17 18:52 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16  2:17 [PATCH bpf 00/12] verify callbacks as if they are called unknown number of times Eduard Zingerman
2023-11-16  2:17 ` [PATCH bpf 01/12] selftests/bpf: track tcp payload offset as scalar in xdp_synproxy Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-16  2:17 ` [PATCH bpf 02/12] selftests/bpf: track string payload offset as scalar in strobemeta Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-17 18:52     ` Eduard Zingerman
2023-11-16  2:17 ` [PATCH bpf 03/12] selftests/bpf: fix bpf_loop_bench for new callback verification scheme Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-17 18:52     ` Eduard Zingerman [this message]
2023-11-17 21:38   ` Alexei Starovoitov
2023-11-17 21:43     ` Eduard Zingerman
2023-11-17 21:47       ` Alexei Starovoitov
2023-11-17 21:50         ` Eduard Zingerman
2023-11-17 21:55           ` Alexei Starovoitov
2023-11-16  2:17 ` [PATCH bpf 04/12] bpf: extract __check_reg_arg() utility function Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-16  2:17 ` [PATCH bpf 05/12] bpf: extract setup_func_entry() " Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-17 18:52     ` Eduard Zingerman
2023-11-16  2:17 ` [PATCH bpf 06/12] bpf: verify callbacks as if they are called unknown number of times Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-17 18:52     ` Eduard Zingerman
2023-11-17 20:27       ` Andrii Nakryiko
2023-11-17 21:03         ` Eduard Zingerman
2023-11-16  2:17 ` [PATCH bpf 07/12] selftests/bpf: tests for iterating callbacks Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-16  2:17 ` [PATCH bpf 08/12] bpf: widening for callback iterators Eduard Zingerman
2023-11-17 16:46   ` Andrii Nakryiko
2023-11-16  2:18 ` [PATCH bpf 09/12] selftests/bpf: test widening for iterating callbacks Eduard Zingerman
2023-11-17 16:47   ` Andrii Nakryiko
2023-11-17 18:53     ` Eduard Zingerman
2023-11-17 20:28       ` Andrii Nakryiko
2023-11-16  2:18 ` [PATCH bpf 10/12] bpf: keep track of max number of bpf_loop callback iterations Eduard Zingerman
2023-11-16 14:08   ` Andrii Nakryiko
2023-11-16 14:13     ` Eduard Zingerman
2023-11-17 16:47   ` Andrii Nakryiko
2023-11-17 18:53     ` Eduard Zingerman
2023-11-17 20:30       ` Andrii Nakryiko
2023-11-16  2:18 ` [PATCH bpf 11/12] selftests/bpf: add __not_msg annotation for test_loader based tests Eduard Zingerman
2023-11-17 16:45   ` Andrii Nakryiko
2023-11-17 18:53     ` Eduard Zingerman
2023-11-17 20:31       ` Andrii Nakryiko
2023-11-17 21:10         ` Eduard Zingerman
2023-11-17 21:33           ` Alexei Starovoitov
2023-11-16  2:18 ` [PATCH bpf 12/12] selftests/bpf: check if max number of bpf_loop iterations is tracked Eduard Zingerman
2023-11-17 16:47   ` Andrii Nakryiko
2023-11-17 18:53     ` Eduard Zingerman
2023-11-17 20:32       ` Andrii Nakryiko
2023-11-17 21:18         ` Eduard Zingerman

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=a2e55bf0b299df0453789a79755c0c4369c5c046.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=awerner32@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.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