|
@@ -1121,6 +1121,16 @@ static int check_alu_op(struct verifier_env *env, struct bpf_insn *insn)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ((opcode == BPF_LSH || opcode == BPF_RSH ||
|
|
|
|
+ opcode == BPF_ARSH) && BPF_SRC(insn->code) == BPF_K) {
|
|
|
|
+ int size = BPF_CLASS(insn->code) == BPF_ALU64 ? 64 : 32;
|
|
|
|
+
|
|
|
|
+ if (insn->imm < 0 || insn->imm >= size) {
|
|
|
|
+ verbose("invalid shift %d\n", insn->imm);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/* pattern match 'bpf_add Rx, imm' instruction */
|
|
/* pattern match 'bpf_add Rx, imm' instruction */
|
|
if (opcode == BPF_ADD && BPF_CLASS(insn->code) == BPF_ALU64 &&
|
|
if (opcode == BPF_ADD && BPF_CLASS(insn->code) == BPF_ALU64 &&
|
|
regs[insn->dst_reg].type == FRAME_PTR &&
|
|
regs[insn->dst_reg].type == FRAME_PTR &&
|