From: Daniel Borkmann Date: Tue, 23 Mar 2021 07:32:59 +0000 (+0100) Subject: bpf: Use correct permission flag for mixed signed bounds arithmetic X-Git-Tag: v5.10.79~5542 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f3ff11204eac0ee23acf64deecb3bad7b0db0c6;p=platform%2Fkernel%2Flinux-rpi.git bpf: Use correct permission flag for mixed signed bounds arithmetic [ Upstream commit 9601148392520e2e134936e76788fc2a6371e7be ] 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: 2c78ee898d8f ("bpf: Implement CAP_BPF") Signed-off-by: Daniel Borkmann Reviewed-by: John Fastabend Acked-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 12cd299..2eaefd9 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5522,7 +5522,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, dst, reg_type_str[ptr_reg->type]); return -EACCES; case PTR_TO_MAP_VALUE: - if (!env->allow_ptr_leaks && !known && (smin_val < 0) != (smax_val < 0)) { + if (!env->env->bypass_spec_v1 && !known && (smin_val < 0) != (smax_val < 0)) { verbose(env, "R%d has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root\n", off_reg == dst_reg ? dst : src); return -EACCES;