Skip to content

Commit 9601148

Browse files
committed
bpf: Use correct permission flag for mixed signed bounds arithmetic
We forbid adding unknown scalars with mixed signed bounds due to the spectre v1 masking mitigation. Hence this also needs bypass_spec_v1 flag instead of allow_ptr_leaks. Fixes: 2c78ee8 ("bpf: Implement CAP_BPF") Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: John Fastabend <[email protected]> Acked-by: Alexei Starovoitov <[email protected]>
1 parent afd0be7 commit 9601148

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6085,7 +6085,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
60856085
dst, reg_type_str[ptr_reg->type]);
60866086
return -EACCES;
60876087
case PTR_TO_MAP_VALUE:
6088-
if (!env->allow_ptr_leaks && !known && (smin_val < 0) != (smax_val < 0)) {
6088+
if (!env->env->bypass_spec_v1 && !known && (smin_val < 0) != (smax_val < 0)) {
60896089
verbose(env, "R%d has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root\n",
60906090
off_reg == dst_reg ? dst : src);
60916091
return -EACCES;

0 commit comments

Comments
 (0)