summaryrefslogtreecommitdiff
path: root/arch/x86/net
diff options
context:
space:
mode:
authorSong Liu <song@kernel.org>2022-02-07 22:25:33 -0800
committerAlexei Starovoitov <ast@kernel.org>2022-02-08 09:23:18 -0800
commitf95f768f0af4cec806ce86cd67934a10617d96d0 (patch)
tree58863b8b7a45ef7b1797d322008a7db3ff2392db /arch/x86/net
parent5d1e9f437df5ef21e7567f1970a00fda3b5d1126 (diff)
bpf, x86_64: Fail gracefully on bpf_jit_binary_pack_finalize failures
Instead of BUG_ON(), fail gracefully and return orig_prog. Fixes: 1022a5498f6f ("bpf, x86_64: Use bpf_jit_binary_pack_alloc") Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220208062533.3802081-1-song@kernel.org
Diffstat (limited to 'arch/x86/net')
-rw-r--r--arch/x86/net/bpf_jit_comp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 643f38b91e30..c7db0fe4de2f 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -2378,9 +2378,13 @@ out_image:
* 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;