From: John Fastabend <john.fastabend@gmail.com>
To: Edward Cree <ecree@solarflare.com>,
netdev <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [RFC PATCH bpf-next 07/12] bpf/verifier: allow bounded loops with JLT/true back-edge
Date: Fri, 23 Feb 2018 14:27:18 -0800 [thread overview]
Message-ID: <abb7c828-fc0f-4279-0b8c-cc70a076e88c@gmail.com> (raw)
In-Reply-To: <dcac2b50-f279-4a56-392d-9b89f6e20e46@solarflare.com>
On 02/23/2018 09:41 AM, Edward Cree wrote:
> Where the register umin_value is increasing sufficiently fast, the loop
> will terminate after a reasonable number of iterations, so we can allow
> to keep walking it.
Continuing to walk the loop is problematic because we hit the complexity
limit. What we want to do is a static analysis step upfront on the basic
block containing the loop to ensure the loop is bounded.
We can do this by finding the induction variables (variables with form
cn+d) and ensuring the comparison register is an induction variable and
also increasing/decreasing correctly with respect to the comparison op.
This seems to be common in compilers to pull computation out of the
loop. So should be doable in the verifier.
> The semantics of prev_insn_idx are changed slightly: it now always refers
> to the last jump insn walked, even when that jump was not taken. Also it
> is moved into env, alongside a new bool last_jump_taken that records
> whether the jump was taken or not. This is needed so that, when we detect
> a loop, we can see how we ended up in the back-edge: what was the jump
> condition, and is it the true- or the false-branch that ends up looping?
> We record in our explored_states whether they represent a conditional jump
> and whether that jump produced a good loop bound. This allows us to make
> unconditional jumps "not responsible" for ensuring the loop is bounded, as
> long as there is a conditional jump somewhere in the loop body; whereas a
> conditional jump must ensure that there is a bounding conditional somewhere
> in the loop body.
> Recursive calls have to remain forbidden because the calculation of maximum
> stack depth assumes the call graph is acyclic, even though the loop
> handling code could determine whether the recursion was bounded.
>
> Signed-off-by: Edward Cree <ecree@solarflare.com>
> ---
next prev parent reply other threads:[~2018-02-23 22:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 17:35 [RFC/PoC PATCH bpf-next 00/12] bounded loops for eBPF Edward Cree
2018-02-23 17:39 ` [RFC PATCH bpf-next 01/12] bpf/verifier: validate func_calls by marking at do_check() time Edward Cree
2018-02-23 17:39 ` [RFC PATCH bpf-next 02/12] bpf/verifier: update selftests Edward Cree
2018-02-23 17:40 ` [RFC PATCH bpf-next 03/12] bpf/verifier: per-register parent pointers Edward Cree
2018-02-23 17:40 ` [RFC PATCH bpf-next 04/12] bpf/verifier: store insn_idx instead of callsite in bpf_func_state Edward Cree
2018-02-23 17:40 ` [RFC PATCH bpf-next 05/12] bpf/verifier: detect loops dynamically rather than statically Edward Cree
2018-02-23 22:27 ` John Fastabend
2018-02-26 12:53 ` Edward Cree
2018-02-23 17:41 ` [RFC PATCH bpf-next 06/12] bpf/verifier: do not walk impossible branches Edward Cree
2018-02-23 17:41 ` [RFC PATCH bpf-next 07/12] bpf/verifier: allow bounded loops with JLT/true back-edge Edward Cree
2018-02-23 22:27 ` John Fastabend [this message]
2018-02-26 11:32 ` Edward Cree
2018-02-23 17:41 ` [RFC PATCH bpf-next 08/12] bpf/verifier: selftests for bounded loops Edward Cree
2018-02-23 17:41 ` [RFC PATCH bpf-next 09/12] bpf/verifier: count still-live children of explored_states Edward Cree
2018-02-23 17:42 ` [RFC PATCH bpf-next 10/12] bpf/verifier: parent state pointer is not per-frame Edward Cree
2018-02-23 17:42 ` [RFC PATCH bpf-next 11/12] bpf/verifier: better detection of statically unreachable code Edward Cree
2018-02-23 17:42 ` [RFC PATCH bpf-next 12/12] bpf/verifier: update selftests Edward Cree
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=abb7c828-fc0f-4279-0b8c-cc70a076e88c@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=ecree@solarflare.com \
--cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).