From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
kernel-team@fb.com, yonghong.song@linux.dev
Subject: Re: [PATCH bpf-next v1 1/2] bpf: states with loop entry have incomplete read/precision marks
Date: Thu, 13 Mar 2025 12:28:56 -0700 [thread overview]
Message-ID: <3c6ac16b7578406e2ddd9ba889ce955748fe636b.camel@gmail.com> (raw)
In-Reply-To: <20250312031344.3735498-1-eddyz87@gmail.com>
On Tue, 2025-03-11 at 20:13 -0700, Eduard Zingerman wrote:
> Suppose the verifier state exploration graph looks as follows:
>
> .-> A --. Suppose:
> | | | - state A is at iterator 'next';
> | v v - path A -> B -> A is verified first;
> '-- B C - path A -> C is verified next;
> - B does not impose a read mark for register R1;
> - C imposes a read mark for register R1;
>
> Under such conditions:
> - when B is explored and A is identified as its loop entry, the read
> marks are copied from A to B by propagate_liveness(), but these
> marks do not include R1;
> - when C is explored, the read mark for R1 is propagated to A,
> but not to B.
> - at this point, state A has its branch count at zero, but state
> B has incomplete read marks.
>
> The same logic applies to precision marks.
> This means that states with a loop entry can have incomplete read and
> precision marks, regardless of whether the loop entry itself has
> branches.
Which makes me wonder.
If read/precision marks for B are not final and some state D outside
of the loop becomes equal to B, the read/precision marks for that
state would be incomplete as well:
D------. // as some read/precision marks are missing from C
| // propagate_liveness() won't copy all necessary
.-> A --. | // marks to D.
| | | |
| v v |
'-- B C |
^ |
'------'
This makes comparison with 'loop_entry' states contagious,
propagating incomplete read/precision mark flag up to the root state.
This will have verification performance implications.
Alternatively read/precision marks need to be propagated in the state
graph until fixed point is reached. Like with DFA analysis.
Решето.
> The current verification logic does not account for this. An example
> of an unsafe program accepted by the verifier is the selftest included
> in the next patch.
[...]
next prev parent reply other threads:[~2025-03-13 19:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 3:13 [PATCH bpf-next v1 1/2] bpf: states with loop entry have incomplete read/precision marks Eduard Zingerman
2025-03-12 3:13 ` [PATCH bpf-next v1 2/2] selftests/bpf: test case with missing read/precision mark Eduard Zingerman
2025-03-13 19:28 ` Eduard Zingerman [this message]
2025-03-14 17:41 ` [PATCH bpf-next v1 1/2] bpf: states with loop entry have incomplete read/precision marks Eduard Zingerman
2025-03-15 2:51 ` Alexei Starovoitov
2025-03-15 6:04 ` Eduard Zingerman
2025-03-17 20:28 ` Eduard Zingerman
2025-03-17 21:46 ` Alexei Starovoitov
2025-03-21 20:02 ` 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=3c6ac16b7578406e2ddd9ba889ce955748fe636b.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--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