From: "Arthur Fabre" <afabre@cloudflare.com>
To: "Eduard Zingerman" <eddyz87@gmail.com>, <bpf@vger.kernel.org>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
<kernel-team@cloudflare.com>
Subject: Re: [PATCH bpf v3 1/2] bpf: Account for early exit of bpf_tail_call() and LD_ABS
Date: Wed, 08 Jan 2025 21:44:17 +0100 [thread overview]
Message-ID: <D6WZGKVYV3G4.3P0J28SSHSHOI@cloudflare.com> (raw)
In-Reply-To: <3f08fa54c29d5716982194801bfdae93c15a8c27.camel@gmail.com>
On Mon Jan 6, 2025 at 9:31 PM CET, Eduard Zingerman wrote:
> On Mon, 2025-01-06 at 18:15 +0100, Arthur Fabre wrote:
[...]
> This patch is correct as far as I can tell.
>
> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Thanks for the review!
> [...]
>
> > @@ -18770,6 +18780,21 @@ static int do_check(struct bpf_verifier_env *env)
> > return err;
> >
> > mark_reg_scratched(env, BPF_REG_0);
> > +
> > + if (insn->src_reg == 0 && insn->imm == BPF_FUNC_tail_call) {
> > + /* Explore both cases: tail_call fails and we fallthrough,
> > + * or it succeeds and we exit the current function.
> > + */
> > + if (!push_stack(env, env->insn_idx + 1, env->insn_idx, false))
> > + return -ENOMEM;
> > + /* bpf_tail_call() doesn't set r0 on failure / in the fallthrough case.
> > + * But it does on success, so we have to mark it after queueing the
> > + * fallthrough case, but before prepare_func_exit().
> > + */
> > + __mark_reg_unknown(env, &state->frame[state->curframe]->regs[BPF_REG_0]);
> > + exit = BPF_EXIT_TAIL_CALL;
> > + goto process_bpf_exit_full;
> > + }
>
> Nit: it's a bit unfortunate, that this logic is inside do_check,
> instead of check_helper_call() and check_ld_abs().
> But it makes BPF_EXIT_* propagation simpler.
Agreed, it's unfortunate to add more to do_check().
I tried passing exit / BPF_EXIT_* by pointer to check_helper_call() and
check_ld_abs(), but that still means we need a conditional in do_check()
to see if it's set:
if (exit != NULL)
oto process_bpf_exit_full;
Happy to switch to that if you think it's cleaner.
[...]
next prev parent reply other threads:[~2025-01-08 20:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 17:15 [PATCH bpf v3 0/2] bpf: Account for early exit of bpf_tail_call() and LD_ABS Arthur Fabre
2025-01-06 17:15 ` [PATCH bpf v3 1/2] " Arthur Fabre
2025-01-06 20:31 ` Eduard Zingerman
2025-01-08 20:44 ` Arthur Fabre [this message]
2025-01-06 17:15 ` [PATCH bpf v3 2/2] selftests/bpf: Test r0 and ref lifetime after BPF-BPF call with abnormal return Arthur Fabre
2025-01-06 20:34 ` Eduard Zingerman
2025-01-08 20:46 ` Arthur Fabre
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=D6WZGKVYV3G4.3P0J28SSHSHOI@cloudflare.com \
--to=afabre@cloudflare.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@cloudflare.com \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--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