]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
bpf: Use correct permission flag for mixed signed bounds arithmetic
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 Mar 2021 07:32:59 +0000 (08:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:13:27 +0000 (13:13 +0200)
[ 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 <daniel@iogearbox.net>
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/verifier.c

index 36b81975d9cda0d9819bdbec4a4fa96f2e8905f7..b654174619e59deec2493d1884668ae29174fccc 100644 (file)
@@ -5578,7 +5578,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;