* [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section
@ 2016-01-21 23:46 Daniel Borkmann
2016-01-22 3:13 ` Alexei Starovoitov
2016-02-02 5:06 ` Stephen Hemminger
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Borkmann @ 2016-01-21 23:46 UTC (permalink / raw)
To: stephen; +Cc: netdev, alexei.starovoitov, Daniel Borkmann
Add a test that symbol from relocation entry is actually related
to map section and bail out with an error message if it's not the
case; in relation to [1].
[1] https://llvm.org/bugs/show_bug.cgi?id=26243
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
tc/tc_bpf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
index 219ffa5..3c97cdb 100644
--- a/tc/tc_bpf.c
+++ b/tc/tc_bpf.c
@@ -1336,6 +1336,12 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
return -EIO;
+ if (sym.st_shndx != ctx->sec_maps) {
+ fprintf(stderr, "ELF contains non-map related relo data in "
+ "entry %u pointing to section %u! Compiler bug?!\n",
+ relo_ent, sym.st_shndx);
+ return -EIO;
+ }
rmap = sym.st_value / sizeof(struct bpf_elf_map);
if (rmap >= ARRAY_SIZE(ctx->map_fds))
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section
2016-01-21 23:46 [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section Daniel Borkmann
@ 2016-01-22 3:13 ` Alexei Starovoitov
2016-02-02 5:06 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2016-01-22 3:13 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: stephen, netdev, wangnan0
On Fri, Jan 22, 2016 at 12:46:28AM +0100, Daniel Borkmann wrote:
> Add a test that symbol from relocation entry is actually related
> to map section and bail out with an error message if it's not the
> case; in relation to [1].
>
> [1] https://llvm.org/bugs/show_bug.cgi?id=26243
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Thanks. Useful check.
Wang, we probably want something like this in libbpf as well.
> ---
> tc/tc_bpf.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
> index 219ffa5..3c97cdb 100644
> --- a/tc/tc_bpf.c
> +++ b/tc/tc_bpf.c
> @@ -1336,6 +1336,12 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
>
> if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
> return -EIO;
> + if (sym.st_shndx != ctx->sec_maps) {
> + fprintf(stderr, "ELF contains non-map related relo data in "
> + "entry %u pointing to section %u! Compiler bug?!\n",
> + relo_ent, sym.st_shndx);
> + return -EIO;
> + }
>
> rmap = sym.st_value / sizeof(struct bpf_elf_map);
> if (rmap >= ARRAY_SIZE(ctx->map_fds))
> --
> 1.9.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section
2016-01-21 23:46 [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section Daniel Borkmann
2016-01-22 3:13 ` Alexei Starovoitov
@ 2016-02-02 5:06 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2016-02-02 5:06 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, alexei.starovoitov
On Fri, 22 Jan 2016 00:46:28 +0100
Daniel Borkmann <daniel@iogearbox.net> wrote:
> Add a test that symbol from relocation entry is actually related
> to map section and bail out with an error message if it's not the
> case; in relation to [1].
>
> [1] https://llvm.org/bugs/show_bug.cgi?id=26243
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
Applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-02 5:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 23:46 [PATCH iproute2 -master] tc, bpf: make sure relo is in relation with map section Daniel Borkmann
2016-01-22 3:13 ` Alexei Starovoitov
2016-02-02 5:06 ` Stephen Hemminger
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).