Re: [PATCH v9 bpf-next 9/9] bpf, x86_64: use bpf_jit_binary_pack_alloc

From: Alexei Starovoitov
Date: Mon Feb 07 2022 - 21:25:08 EST


On Fri, Feb 04, 2022 at 10:57:42AM -0800, Song Liu wrote:
> if (image) {
> if (!prog->is_func || extra_pass) {
> + /*
> + * bpf_jit_binary_pack_finalize fails in two scenarios:
> + * 1) header is not pointing to proper module memory;
> + * 2) the arch doesn't support bpf_arch_text_copy().
> + *
> + * Both cases are serious bugs that we should not continue.
> + */
> + BUG_ON(bpf_jit_binary_pack_finalize(prog, header, rw_header));
> bpf_tail_call_direct_fixup(prog);
> - bpf_jit_binary_lock_ro(header);

BUG_ON is discouraged.
It should only be used when the kernel absolutely cannot continue.
Here ro/rw_headers will be freed. We can WARN and goto out_addrs without drama.
Please send a follow up.

The rest looks great. Applied to bpf-next.