From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org
Cc: kernel-team@meta.com
Subject: Re: [PATCH bpf-next 2/3] bpf: validate global subprogs lazily
Date: Thu, 23 Nov 2023 17:26:55 +0200 [thread overview]
Message-ID: <e1f42067ede02cf159ab8cd0172e8810ec733cf2.camel@gmail.com> (raw)
In-Reply-To: <20231122213112.3596548-3-andrii@kernel.org>
On Wed, 2023-11-22 at 13:31 -0800, Andrii Nakryiko wrote:
> Slightly change BPF verifier logic around eagerness and order of global
> subprog validation. Instead of going over every global subprog eagerly
> and validating it before main (entry) BPF program is verified, turn it
> around. Validate main program first, mark subprogs that were called from
> main program for later verification, but otherwise assume it is valid.
> Afterwards, go over marked global subprogs and validate those,
> potentially marking some more global functions as being called. Continue
> this process until all (transitively) callable global subprogs are
> validated. It's a BFS traversal at its heart and will always converge.
>
> This is an important change because it allows to feature-gate some
> subprograms that might not be verifiable on some older kernel, depending
> on supported set of features.
>
[...]
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmai.com>
[...]
> @@ -19761,14 +19772,26 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog, bool is_ex
> static int do_check_subprogs(struct bpf_verifier_env *env)
> {
> struct bpf_prog_aux *aux = env->prog->aux;
> - int i, ret;
> + struct bpf_func_info_aux *sub_aux;
> + int i, ret, new_cnt;
>
> if (!aux->func_info)
> return 0;
>
> + /* exception callback is presumed to be always called */
> + if (env->exception_callback_subprog)
> + subprog_aux(env, env->exception_callback_subprog)->called = true;
> +
> +again:
Nit: I'd use an explicit loop and a separate function here,
but kernel people like their gotos...
[...]
next prev parent reply other threads:[~2023-11-23 15:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 21:31 [PATCH bpf-next 0/3] Verify global subprogs lazily Andrii Nakryiko
2023-11-22 21:31 ` [PATCH bpf-next 1/3] bpf: emit global subprog name in verifier logs Andrii Nakryiko
2023-11-23 15:26 ` Eduard Zingerman
2023-11-22 21:31 ` [PATCH bpf-next 2/3] bpf: validate global subprogs lazily Andrii Nakryiko
2023-11-23 15:26 ` Eduard Zingerman [this message]
2023-11-22 21:31 ` [PATCH bpf-next 3/3] selftests/bpf: add lazy global subprog validation tests Andrii Nakryiko
2023-11-23 15:27 ` Eduard Zingerman
2023-11-23 22:48 ` [PATCH bpf-next 0/3] Verify global subprogs lazily Daniel Borkmann
2023-11-24 3:31 ` Andrii Nakryiko
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=e1f42067ede02cf159ab8cd0172e8810ec733cf2.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@meta.com \
--cc=martin.lau@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