mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-13 11:05:50 +00:00
bpf: also check elf for official e_machine value
Use the official BPF ELF e_machine value that was assigned recently [1]
and will be propagated to glibc, libelf et al. LLVM will switch to it
in 3.9 release, therefore we need to prepare tc to check for EM_ELF as
well, older version still have the EM_NONE.
[1] 36b9c09330
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
78c610e6ea
commit
e77fa41d4c
@ -54,6 +54,10 @@
|
|||||||
#define AF_ALG 38
|
#define AF_ALG 38
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EM_BPF
|
||||||
|
#define EM_BPF 247
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ELF
|
#ifdef HAVE_ELF
|
||||||
static int bpf_obj_open(const char *path, enum bpf_prog_type type,
|
static int bpf_obj_open(const char *path, enum bpf_prog_type type,
|
||||||
const char *sec, bool verbose);
|
const char *sec, bool verbose);
|
||||||
@ -1690,7 +1694,8 @@ static void bpf_hash_destroy(struct bpf_elf_ctx *ctx)
|
|||||||
static int bpf_elf_check_ehdr(const struct bpf_elf_ctx *ctx)
|
static int bpf_elf_check_ehdr(const struct bpf_elf_ctx *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->elf_hdr.e_type != ET_REL ||
|
if (ctx->elf_hdr.e_type != ET_REL ||
|
||||||
ctx->elf_hdr.e_machine != 0 ||
|
(ctx->elf_hdr.e_machine != EM_NONE &&
|
||||||
|
ctx->elf_hdr.e_machine != EM_BPF) ||
|
||||||
ctx->elf_hdr.e_version != EV_CURRENT) {
|
ctx->elf_hdr.e_version != EV_CURRENT) {
|
||||||
fprintf(stderr, "ELF format error, ELF file not for eBPF?\n");
|
fprintf(stderr, "ELF format error, ELF file not for eBPF?\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user