]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc, bpf: make sure relo is in relation with map section
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Jan 2016 23:46:28 +0000 (00:46 +0100)
committerStephen Hemminger <shemming@brocade.com>
Tue, 2 Feb 2016 05:04:11 +0000 (16:04 +1100)
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>
tc/tc_bpf.c

index 42c8841869f5547032946cba5cfe03243de39ed4..955bd5fbfc2b5819dad2c0b8c49889efd7be1fe1 100644 (file)
@@ -1328,6 +1328,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))