netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf, x86_64: fail gracefully on bpf_jit_binary_pack_finalize failures
@ 2022-02-08  6:25 Song Liu
  2022-02-08 17:28 ` Alexei Starovoitov
  2022-02-08 17:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Song Liu @ 2022-02-08  6:25 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, andrii, kernel-team, Song Liu

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>
---
 arch/x86/net/bpf_jit_comp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 643f38b91e30..08e8fd8f954a 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -2380,7 +2380,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 			 *
 			 * Both cases are serious bugs that we should not continue.
 			 */
-			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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-08 17:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08  6:25 [PATCH bpf-next] bpf, x86_64: fail gracefully on bpf_jit_binary_pack_finalize failures Song Liu
2022-02-08 17:28 ` Alexei Starovoitov
2022-02-08 17:34   ` Song Liu
2022-02-08 17:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).