From 28b2d3d112e2bde5264921d8feca89e2e5708a87 Mon Sep 17 00:00:00 2001 From: Konstantin Ananyev Date: Fri, 21 Jun 2019 15:26:49 +0100 Subject: [PATCH] bpf: fix check array size Array ins_chk in lib/librte_bpf/bpf_validate.c has 255 entries. So the instruction with opcode == 255 will reading beyond array boundaries. For more details please refer to: https://bugs.dpdk.org/show_bug.cgi?id=283 Fixes: 6e12ec4c4d6d ("bpf: add more checks") Cc: stable@dpdk.org Reported-by: Michel Machado Signed-off-by: Konstantin Ananyev --- lib/librte_bpf/bpf_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c index 83983efc4e..d0e683b5b2 100644 --- a/lib/librte_bpf/bpf_validate.c +++ b/lib/librte_bpf/bpf_validate.c @@ -1084,7 +1084,7 @@ eval_jcc(struct bpf_verifier *bvf, const struct ebpf_insn *ins) /* * validate parameters for each instruction type. */ -static const struct bpf_ins_check ins_chk[UINT8_MAX] = { +static const struct bpf_ins_check ins_chk[UINT8_MAX + 1] = { /* ALU IMM 32-bit instructions */ [(BPF_ALU | BPF_ADD | BPF_K)] = { .mask = {.dreg = WRT_REGS, .sreg = ZERO_REG}, -- 2.20.1