bpf: Replace hard-coded 0 with BPF_K in check_alu_op
authorSimon Wang <wangchuanguo@inspur.com>
Wed, 22 Jun 2022 03:19:23 +0000 (23:19 -0400)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 24 Jun 2022 13:40:42 +0000 (15:40 +0200)
Enhance readability a bit.

Signed-off-by: Simon Wang <wangchuanguo@inspur.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20220622031923.65692-1-wangchuanguo@inspur.com
kernel/bpf/verifier.c

index a20d773..f228141 100644 (file)
@@ -9096,7 +9096,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
 
        if (opcode == BPF_END || opcode == BPF_NEG) {
                if (opcode == BPF_NEG) {
-                       if (BPF_SRC(insn->code) != 0 ||
+                       if (BPF_SRC(insn->code) != BPF_K ||
                            insn->src_reg != BPF_REG_0 ||
                            insn->off != 0 || insn->imm != 0) {
                                verbose(env, "BPF_NEG uses reserved fields\n");