Skip to content

Commit 683b96f

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
bpf: extract __check_reg_arg() utility function
Split check_reg_arg() into two utility functions: - check_reg_arg() operating on registers from current verifier state; - __check_reg_arg() operating on a specific set of registers passed as a parameter; The __check_reg_arg() function would be used by a follow-up change for callbacks handling. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20231121020701.26440-5-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent f40bfd1 commit 683b96f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

kernel/bpf/verifier.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,13 +3439,11 @@ static void mark_insn_zext(struct bpf_verifier_env *env,
34393439
reg->subreg_def = DEF_NOT_SUBREG;
34403440
}
34413441

3442-
static int check_reg_arg(struct bpf_verifier_env *env, u32 regno,
3443-
enum reg_arg_type t)
3442+
static int __check_reg_arg(struct bpf_verifier_env *env, struct bpf_reg_state *regs, u32 regno,
3443+
enum reg_arg_type t)
34443444
{
3445-
struct bpf_verifier_state *vstate = env->cur_state;
3446-
struct bpf_func_state *state = vstate->frame[vstate->curframe];
34473445
struct bpf_insn *insn = env->prog->insnsi + env->insn_idx;
3448-
struct bpf_reg_state *reg, *regs = state->regs;
3446+
struct bpf_reg_state *reg;
34493447
bool rw64;
34503448

34513449
if (regno >= MAX_BPF_REG) {
@@ -3486,6 +3484,15 @@ static int check_reg_arg(struct bpf_verifier_env *env, u32 regno,
34863484
return 0;
34873485
}
34883486

3487+
static int check_reg_arg(struct bpf_verifier_env *env, u32 regno,
3488+
enum reg_arg_type t)
3489+
{
3490+
struct bpf_verifier_state *vstate = env->cur_state;
3491+
struct bpf_func_state *state = vstate->frame[vstate->curframe];
3492+
3493+
return __check_reg_arg(env, state->regs, regno, t);
3494+
}
3495+
34893496
static void mark_jmp_point(struct bpf_verifier_env *env, int idx)
34903497
{
34913498
env->insn_aux_data[idx].jmp_point = true;
@@ -9350,7 +9357,7 @@ static void clear_caller_saved_regs(struct bpf_verifier_env *env,
93509357
/* after the call registers r0 - r5 were scratched */
93519358
for (i = 0; i < CALLER_SAVED_REGS; i++) {
93529359
mark_reg_not_init(env, regs, caller_saved[i]);
9353-
check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
9360+
__check_reg_arg(env, regs, caller_saved[i], DST_OP_NO_MARK);
93549361
}
93559362
}
93569363

0 commit comments

Comments
 (0)