From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH v3 bpf-next 1/2] bpf: Relax precision marking in open coded iters and may_goto loop.
Date: Wed, 29 May 2024 03:14:43 -0700 [thread overview]
Message-ID: <62cf34743e05aacfc754fbb84a0e1eeba14e76d2.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQKczx0pNt7f8vYmknyg7cBxrr8raOpVKmxfnSjT3UO1OQ@mail.gmail.com>
On Tue, 2024-05-28 at 20:22 -0700, Alexei Starovoitov wrote:
[...]
>
> > However, below is an example where if comparison is BPF_X.
> > Note that I obfuscated constant 5 as a volatile variable.
> > And here is what happens when verifier rejects the program:
>
> Sounds pretty much like: doctor it hurts when I do that.
Well, the point is not in the volatile variable but in the BPF_X
comparison instruction. The bound might a size of some buffer,
e.g. encoded like this:
struct foo {
int *items;
int max_items; // suppose this is 5 for some verification path
}; // and 7 for another.
And you don't need bpf_for specifically, an outer loop with
can_loop should also lead to get_loop_entry(...) being non-NULL.
> > + volatile unsigned long five = 5;
> > + unsigned long sum = 0, i = 0;
> > + struct bpf_iter_num it;
> > + int *v;
> > +
> > + bpf_iter_num_new(&it, 0, 10);
> > + while ((v = bpf_iter_num_next(&it))) {
> > + if (i < five)
> > + sum += arr[i++];
>
> If you're saying that the verifier should accept that
> no matter what then I have to disagree.
> Not interested in avoiding issues in programs that
> are actively looking to explore a verifier implementation detail.
I don't think that this is a very exotic pattern,
such code could be written if one has a buffer with a dynamic bound
and seeks to fill it with items from some collection applying filtering.
I do not insist that varifier should accept such programs,
but since we are going for heuristics to do the widening,
I think we should try and figure out a few examples when
heuristics breaks, just to understand if that is ok.
next prev parent reply other threads:[~2024-05-29 10:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-25 3:11 [PATCH v3 bpf-next 1/2] bpf: Relax precision marking in open coded iters and may_goto loop Alexei Starovoitov
2024-05-25 3:11 ` [PATCH v3 bpf-next 2/2] selftests/bpf: Remove i = zero workaround and add new tests Alexei Starovoitov
2024-05-27 7:26 ` [PATCH v3 bpf-next 1/2] bpf: Relax precision marking in open coded iters and may_goto loop Dan Carpenter
2024-05-27 22:44 ` Alexei Starovoitov
2024-05-29 14:32 ` Dan Carpenter
2024-05-28 4:10 ` Eduard Zingerman
2024-05-29 0:34 ` Alexei Starovoitov
2024-05-29 1:08 ` Eduard Zingerman
2024-05-29 2:18 ` Eduard Zingerman
2024-05-29 3:22 ` Alexei Starovoitov
2024-05-29 10:14 ` Eduard Zingerman [this message]
2024-06-01 3:08 ` Alexei Starovoitov
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=62cf34743e05aacfc754fbb84a0e1eeba14e76d2.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
/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