From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Eduard Zingerman <eddyz87@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,
john.fastabend@gmail.com,
Andrii Nakryiko <andrii.nakryiko@gmail.com>
Subject: Re: [PATCH bpf-next 1/5] bpf: exact states comparison for iterator convergence checks
Date: Sat, 21 Oct 2023 14:41:10 -0700 [thread overview]
Message-ID: <20231021214110.cpgk32tqaerzbvbe@MacBook-Pro-49.local> (raw)
In-Reply-To: <20231021005939.1041-2-eddyz87@gmail.com>
On Sat, Oct 21, 2023 at 03:59:35AM +0300, Eduard Zingerman wrote:
>
> +static struct bpf_verifier_state_list **__explored_state(struct bpf_verifier_env *env,
> + int idx,
> + int callsite);
...
> +static struct bpf_verifier_state *find_prev_entry(struct bpf_verifier_env *env,
> + struct bpf_verifier_state *cur,
> + int insn_idx)
> +{
> + struct bpf_verifier_state_list *sl;
> + struct bpf_verifier_state *st;
> +
> + /* Explored states are pushed in stack order, most recent states come first */
> + sl = *__explored_state(env, insn_idx, cur->frame[cur->curframe]->callsite);
...
> + prev_st = find_prev_entry(env, cur_st->parent, insn_idx);
...
> +static struct bpf_verifier_state_list **__explored_state(struct bpf_verifier_env *env,
> + int idx,
> + int callsite)
> +{
> + return &env->explored_states[(idx ^ callsite) % state_htab_size(env)];
> +}
> +
> static struct bpf_verifier_state_list **explored_state(
> struct bpf_verifier_env *env,
> int idx)
> @@ -15032,7 +15161,7 @@ static struct bpf_verifier_state_list **explored_state(
> struct bpf_verifier_state *cur = env->cur_state;
> struct bpf_func_state *state = cur->frame[cur->curframe];
>
> - return &env->explored_states[(idx ^ state->callsite) % state_htab_size(env)];
> + return __explored_state(env, idx, state->callsite);
> }
Do we really need to introduce this new helper?
I suspect the concern was that cur->callsite != cur->parent->callsite, right?
But that can never be the case, since bpf_iter_num_next() is force checkpoint,
so inside process_iter_next_call() cur_st->parent is guaranteed to be from
the same function and callsites will be the same.
I can undo above and replace with a warn_on (or with a comment) while applying?
next prev parent reply other threads:[~2023-10-21 21:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 0:59 [PATCH bpf-next 0/5] exact states comparison for iterator convergence checks Eduard Zingerman
2023-10-21 0:59 ` [PATCH bpf-next 1/5] bpf: " Eduard Zingerman
2023-10-21 21:41 ` Alexei Starovoitov [this message]
2023-10-21 0:59 ` [PATCH bpf-next 2/5] selftests/bpf: tests with delayed read/precision makrs in loop body Eduard Zingerman
2023-10-21 7:18 ` kernel test robot
2023-10-21 0:59 ` [PATCH bpf-next 3/5] bpf: correct loop detection for iterators convergence Eduard Zingerman
2023-10-21 0:59 ` [PATCH bpf-next 4/5] selftests/bpf: test if state loops are detected in a tricky case Eduard Zingerman
2023-10-21 7:30 ` kernel test robot
2023-10-21 0:59 ` [PATCH bpf-next 5/5] bpf: print full verifier states on infinite loop detection 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=20231021214110.cpgk32tqaerzbvbe@MacBook-Pro-49.local \
--to=alexei.starovoitov@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=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--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