Skip to content

Commit c5bcb5e

Browse files
bjackmanAlexei Starovoitov
authored andcommitted
bpf: Move BPF_STX reserved field check into BPF_STX verifier code
I can't find a reason why this code is in resolve_pseudo_ldimm64; since I'll be modifying it in a subsequent commit, tidy it up. Signed-off-by: Brendan Jackman <jackmanb@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20210114181751.768687-6-jackmanb@google.com
1 parent 91c960b commit c5bcb5e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎kernel/bpf/verifier.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9528,6 +9528,12 @@ static int do_check(struct bpf_verifier_env *env)
95289528
} else if (class == BPF_STX) {
95299529
enum bpf_reg_type *prev_dst_type, dst_reg_type;
95309530

9531+
if (((BPF_MODE(insn->code) != BPF_MEM &&
9532+
BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) {
9533+
verbose(env, "BPF_STX uses reserved fields\n");
9534+
return -EINVAL;
9535+
}
9536+
95319537
if (BPF_MODE(insn->code) == BPF_ATOMIC) {
95329538
err = check_atomic(env, env->insn_idx, insn);
95339539
if (err)
@@ -10012,13 +10018,6 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
1001210018
return -EINVAL;
1001310019
}
1001410020

10015-
if (BPF_CLASS(insn->code) == BPF_STX &&
10016-
((BPF_MODE(insn->code) != BPF_MEM &&
10017-
BPF_MODE(insn->code) != BPF_ATOMIC) || insn->imm != 0)) {
10018-
verbose(env, "BPF_STX uses reserved fields\n");
10019-
return -EINVAL;
10020-
}
10021-
1002210021
if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
1002310022
struct bpf_insn_aux_data *aux;
1002410023
struct bpf_map *map;

0 commit comments

Comments
 (0)