[PATCH iproute2] bpf: indicate lderr when bpf_apply_relo_data fails

Subsystems: library code, the rest

STALE3398d

3 messages, 2 authors, 2017-06-27 · open the first message on its own page

[PATCH iproute2] bpf: indicate lderr when bpf_apply_relo_data fails

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2017-06-27 00:48:55

When LLVM wrongly generates a rodata relo entry (llvm BZ #33599),
then just bail out instead of probing for prog w/o reloc, which
will fail in this case anyway.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 lib/bpf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index ae4d97d..6b5a96d 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -1795,8 +1795,10 @@ static int bpf_fetch_prog_relo(struct bpf_elf_ctx *ctx, const char *section,
 		*sseen = true;
 
 		ret = bpf_apply_relo_data(ctx, &data_relo, &data_insn);
-		if (ret < 0)
+		if (ret < 0) {
+			*lderr = true;
 			return ret;
+		}
 
 		memset(&prog, 0, sizeof(prog));
 		prog.type    = ctx->type;
-- 
1.9.3

Re: [PATCH iproute2] bpf: indicate lderr when bpf_apply_relo_data fails

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-06-27 23:09:42

On Tue, 27 Jun 2017 02:48:36 +0200
Daniel Borkmann [off-list ref] wrote:
When LLVM wrongly generates a rodata relo entry (llvm BZ #33599),
then just bail out instead of probing for prog w/o reloc, which
will fail in this case anyway.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied, but don't you want a reasonable error message.

Re: [PATCH iproute2] bpf: indicate lderr when bpf_apply_relo_data fails

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2017-06-27 23:14:35

On 06/28/2017 01:09 AM, Stephen Hemminger wrote:
On Tue, 27 Jun 2017 02:48:36 +0200
Daniel Borkmann [off-list ref] wrote:
quoted
When LLVM wrongly generates a rodata relo entry (llvm BZ #33599),
then just bail out instead of probing for prog w/o reloc, which
will fail in this case anyway.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied, but don't you want a reasonable error message.
Thanks, the error message in this case throws:

ELF contains non-map related relo data in entry <X> pointing to section <Y>! Compiler bug?!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help