diff options
author | Alexei Starovoitov <ast@plumgrid.com> | 2015-09-08 16:40:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-09 17:11:55 -0400 |
commit | 687f07156b0c99205c21aa4e2986564046d342fe (patch) | |
tree | 668c2682acff45a945833a56f80f8282a98ae8fd /kernel/bpf/verifier.c | |
parent | 6b9ea5a64ed5eeb3f68f2e6fcce0ed1179801d1e (diff) |
bpf: fix out of bounds access in verifier log
when the verifier log is enabled the print_bpf_insn() is doing
bpf_alu_string[BPF_OP(insn->code) >> 4]
and
bpf_jmp_string[BPF_OP(insn->code) >> 4]
where BPF_OP is a 4-bit instruction opcode.
Malformed insns can cause out of bounds access.
Fix it by sizing arrays appropriately.
The bug was found by clang address sanitizer with libfuzzer.
Reported-by: Yonghong Song <yhs@plumgrid.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/verifier.c')
-rw-r--r-- | kernel/bpf/verifier.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ed12e385fb75..b074b23000d6 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
@@ -283,7 +283,7 @@ static const char *const bpf_class_string[] = { | |||
283 | [BPF_ALU64] = "alu64", | 283 | [BPF_ALU64] = "alu64", |
284 | }; | 284 | }; |
285 | 285 | ||
286 | static const char *const bpf_alu_string[] = { | 286 | static const char *const bpf_alu_string[16] = { |
287 | [BPF_ADD >> 4] = "+=", | 287 | [BPF_ADD >> 4] = "+=", |
288 | [BPF_SUB >> 4] = "-=", | 288 | [BPF_SUB >> 4] = "-=", |
289 | [BPF_MUL >> 4] = "*=", | 289 | [BPF_MUL >> 4] = "*=", |
@@ -307,7 +307,7 @@ static const char *const bpf_ldst_string[] = { | |||
307 | [BPF_DW >> 3] = "u64", | 307 | [BPF_DW >> 3] = "u64", |
308 | }; | 308 | }; |
309 | 309 | ||
310 | static const char *const bpf_jmp_string[] = { | 310 | static const char *const bpf_jmp_string[16] = { |
311 | [BPF_JA >> 4] = "jmp", | 311 | [BPF_JA >> 4] = "jmp", |
312 | [BPF_JEQ >> 4] = "==", | 312 | [BPF_JEQ >> 4] = "==", |
313 | [BPF_JGT >> 4] = ">", | 313 | [BPF_JGT >> 4] = ">", |