[PATCH bpf-next v2 1/3] bpf: add a helper to set preciseness of an unknown register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 kernel/bpf/verifier.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 9f59f7a19dd0..a344b08aef77 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -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)
-- 
2.17.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux