Commit f95f768f authored by Song Liu's avatar Song Liu Committed by Alexei Starovoitov
Browse files

bpf, x86_64: Fail gracefully on bpf_jit_binary_pack_finalize failures



Instead of BUG_ON(), fail gracefully and return orig_prog.

Fixes: 1022a549 ("bpf, x86_64: Use bpf_jit_binary_pack_alloc")
Signed-off-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220208062533.3802081-1-song@kernel.org
parent 5d1e9f43
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2378,9 +2378,13 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
			 *   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.
			 * Both cases are serious bugs and justify WARN_ON.
			 */
			BUG_ON(bpf_jit_binary_pack_finalize(prog, header, rw_header));
			if (WARN_ON(bpf_jit_binary_pack_finalize(prog, header, rw_header))) {
				prog = orig_prog;
				goto out_addrs;
			}

			bpf_tail_call_direct_fixup(prog);
		} else {
			jit_data->addrs = addrs;