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, sunhao.th@gmail.com
Subject: Re: [PATCH bpf-next 1/4] bpf: replace env->cur_hist_ent with a getter function
Date: Wed, 28 Feb 2024 23:23:57 +0200 [thread overview]
Message-ID: <b68297add3d07f3beb08fdaf7d7208d52e47976c.camel@gmail.com> (raw)
In-Reply-To: <CAEf4BzYDtaLU6qXdfVz5gw-Z8Dug35PFDqzBzsbnVXDnP=6X6g@mail.gmail.com>
On Wed, 2024-02-28 at 11:46 -0800, Andrii Nakryiko wrote:
[...]
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index 011d54a1dc53..759ef089b33c 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -3304,24 +3304,34 @@ static bool is_jmp_point(struct bpf_verifier_env *env, int insn_idx)
> > return env->insn_aux_data[insn_idx].jmp_point;
> > }
> >
> > +static struct bpf_jmp_history_entry *get_jmp_hist_entry(struct bpf_verifier_state *st,
> > + u32 hist_end, int insn_idx)
> > +{
> > + if (hist_end > 0 && st->jmp_history[hist_end - 1].idx == insn_idx)
> > + return &st->jmp_history[hist_end - 1];
> > + return NULL;
> > +}
> > +
> > /* for any branch, call, exit record the history of jmps in the given state */
> > static int push_jmp_history(struct bpf_verifier_env *env, struct bpf_verifier_state *cur,
> > int insn_flags)
> > {
> > + struct bpf_jmp_history_entry *p, *cur_hist_ent;
> > u32 cnt = cur->jmp_history_cnt;
> > - struct bpf_jmp_history_entry *p;
> > size_t alloc_size;
> >
> > + cur_hist_ent = get_jmp_hist_entry(cur, cnt, env->insn_idx);
> > +
>
> This is, generally speaking, not correct to do. You can have a tight
> loop where the instruction with the same insn_idx is executed multiple
> times and so we'll get multiple consecutive entries in jmp_history
> with the same insn_idx. We shouldn't reuse hist_ent for all of them,
> each simulated instruction execution should have its own entry in jump
> history.
You are correct.
> It's fine to use get_jmp_hist_entry() in backtracking, though.
>
> I'll look through the rest of patches more closely first before
> suggesting any alternatives. But what you do in this patch is not 100%
> correct.
No need, the patch-set does not rely on capability to push entry for
several states simultaneously. I'll just drop this patch from v2.
[...]
next prev parent reply other threads:[~2024-02-28 21:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 0:50 [PATCH bpf-next 0/4] bpf: track find_equal_scalars history on per-instruction level Eduard Zingerman
2024-02-22 0:50 ` [PATCH bpf-next 1/4] bpf: replace env->cur_hist_ent with a getter function Eduard Zingerman
2024-02-28 19:46 ` Andrii Nakryiko
2024-02-28 21:23 ` Eduard Zingerman [this message]
2024-02-22 0:50 ` [PATCH bpf-next 2/4] bpf: track find_equal_scalars history on per-instruction level Eduard Zingerman
2024-02-28 19:58 ` Andrii Nakryiko
2024-02-28 21:16 ` Eduard Zingerman
2024-02-28 21:36 ` Andrii Nakryiko
2024-02-28 22:39 ` Eduard Zingerman
2024-02-28 21:40 ` Andrii Nakryiko
2024-02-28 23:01 ` Andrii Nakryiko
2024-02-28 23:29 ` Eduard Zingerman
2024-03-01 17:34 ` Andrii Nakryiko
2024-03-01 17:44 ` Eduard Zingerman
2024-03-04 23:37 ` Andrii Nakryiko
2024-02-22 0:50 ` [PATCH bpf-next 3/4] bpf: remove mark_precise_scalar_ids() Eduard Zingerman
2024-02-22 0:50 ` [PATCH bpf-next 4/4] selftests/bpf: tests for per-insn find_equal_scalars() precision tracking 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=b68297add3d07f3beb08fdaf7d7208d52e47976c.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@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=sunhao.th@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