From: Song Liu <song@kernel.org>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<kernel-team@fb.com>, Song Liu <song@kernel.org>
Subject: [PATCH bpf-next] bpf, x86_64: fail gracefully on bpf_jit_binary_pack_finalize failures
Date: Mon, 7 Feb 2022 22:25:33 -0800 [thread overview]
Message-ID: <20220208062533.3802081-1-song@kernel.org> (raw)
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
next reply other threads:[~2022-02-08 6:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 6:25 Song Liu [this message]
2022-02-08 17:28 ` [PATCH bpf-next] bpf, x86_64: fail gracefully on bpf_jit_binary_pack_finalize failures Alexei Starovoitov
2022-02-08 17:34 ` Song Liu
2022-02-08 17:30 ` patchwork-bot+netdevbpf
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=20220208062533.3802081-1-song@kernel.org \
--to=song@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).