Skip to contentSkip to conversation

bpf/verifier: disallow pointer subtraction

PATCH Applied Alexei Starovoitov 2 participants 2 messages Sep 13, 2018

Subsystems (4)
lore
Share & tools
lore

Alexei Starovoitov

author maintainer
#0 lore raw

PATCH 1/1 bpf/verifier: disallow pointer subtraction

Subtraction of pointers was accidentally allowed for unpriv programs by commit 82abbf8d2fc4. Revert that part of commit.

Fixes 82abbf8d2fc4 ("bpf: do not allow root to mangle valid pointers")
---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
index 92246117d2b0..bb07e74b34a2 100644
@@ -3163,7 +3163,7 @@ static int adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 				 * an arbitrary scalar. Disallow all math except
 				 * pointer subtraction
 				 */
-				if (opcode == BPF_SUB){
+				if (opcode == BPF_SUB && env->allow_ptr_leaks) {
 					mark_reg_unknown(env, regs, insn->dst_reg);
 					return 0;
 				}
Signature · 1 line
2.17.1