@@ -1007,6 +1007,14 @@ static void __reg_bound_offset(struct bpf_reg_state *reg)
reg->umax_value));
}
+/* constant backtracking is enabled for root without bpf2bpf calls */
+static void __set_unknown_reg_precise(struct bpf_verifier_env *env,
+ struct bpf_reg_state *reg)
+{
+ reg->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ?
+ true : false;
+}
+
/* Reset the min/max bounds of a register */
static void __mark_reg_unbounded(struct bpf_reg_state *reg)
{
@@ -1042,9 +1050,7 @@ static void mark_reg_unknown(struct bpf_verifier_env *env,
}
regs += regno;
__mark_reg_unknown(regs);
- /* constant backtracking is enabled for root without bpf2bpf calls */
- regs->precise = env->subprog_cnt > 1 || !env->allow_ptr_leaks ?
- true : false;
+ __set_unknown_reg_precise(env, regs);
}
static void __mark_reg_not_init(struct bpf_reg_state *reg)
The patch refactored verifier.c function __mark_reg_unbounded() to have a helper function __set_unknown_reg_precise() to set the preciseness of an unknown register. The helper will be used in the next patch to set the preciseness of an unknown sub-register. Signed-off-by: Yonghong Song <yhs@fb.com> --- kernel/bpf/verifier.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)