diff options
author | Alex Shi <alex.shi@linaro.org> | 2017-11-22 12:01:52 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2017-11-22 12:01:52 +0800 |
commit | c0426ccf530144f8af2e68165aa10cc52cd8f803 (patch) | |
tree | 64ac84f89d8549abfdf4169dd722881f2ca759d1 /kernel | |
parent | ffd95f430f715eb4b86e158a4cff2db55e0d86f8 (diff) | |
parent | 26d6298789e695c9f627ce49a7bbd2286405798a (diff) |
Merge tag 'v4.4.100' into linux-linaro-lsk-v4.4
This is the 4.4.100 stable release
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/verifier.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 70dc6dcf8649..eb759f5008b8 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -313,7 +313,8 @@ static const char *const bpf_jmp_string[16] = { [BPF_EXIT >> 4] = "exit", }; -static void print_bpf_insn(struct bpf_insn *insn) +static void print_bpf_insn(const struct verifier_env *env, + const struct bpf_insn *insn) { u8 class = BPF_CLASS(insn->code); @@ -377,9 +378,19 @@ static void print_bpf_insn(struct bpf_insn *insn) insn->code, bpf_ldst_string[BPF_SIZE(insn->code) >> 3], insn->src_reg, insn->imm); - } else if (BPF_MODE(insn->code) == BPF_IMM) { - verbose("(%02x) r%d = 0x%x\n", - insn->code, insn->dst_reg, insn->imm); + } else if (BPF_MODE(insn->code) == BPF_IMM && + BPF_SIZE(insn->code) == BPF_DW) { + /* At this point, we already made sure that the second + * part of the ldimm64 insn is accessible. + */ + u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; + bool map_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD; + + if (map_ptr && !env->allow_ptr_leaks) + imm = 0; + + verbose("(%02x) r%d = 0x%llx\n", insn->code, + insn->dst_reg, (unsigned long long)imm); } else { verbose("BUG_ld_%02x\n", insn->code); return; @@ -1764,7 +1775,7 @@ static int do_check(struct verifier_env *env) if (log_level) { verbose("%d: ", insn_idx); - print_bpf_insn(insn); + print_bpf_insn(env, insn); } if (class == BPF_ALU || class == BPF_ALU64) { |