Skip to content

Commit 6f6edc4

Browse files
haoluo1022gregkh
authored andcommitted
bpf: Convert PTR_TO_MEM_OR_NULL to composable types.
commit cf9f2f8 upstream. Remove PTR_TO_MEM_OR_NULL and replace it with PTR_TO_MEM combined with flag PTR_MAYBE_NULL. Signed-off-by: Hao Luo <haoluo@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211217003152.48334-7-haoluo@google.com Cc: stable@vger.kernel.org # 5.16.x Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e982070 commit 6f6edc4

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎include/linux/bpf.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ enum bpf_reg_type {
506506
PTR_TO_SOCK_COMMON_OR_NULL = PTR_MAYBE_NULL | PTR_TO_SOCK_COMMON,
507507
PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK,
508508
PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID,
509-
PTR_TO_MEM_OR_NULL = PTR_MAYBE_NULL | PTR_TO_MEM,
510509

511510
/* This must be the last entry. Its purpose is to ensure the enum is
512511
* wide enough to hold the higher bits reserved for bpf_type_flag.

‎kernel/bpf/btf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5847,7 +5847,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
58475847
return -EINVAL;
58485848
}
58495849

5850-
reg->type = PTR_TO_MEM_OR_NULL;
5850+
reg->type = PTR_TO_MEM | PTR_MAYBE_NULL;
58515851
reg->id = ++env->id_gen;
58525852

58535853
continue;

‎kernel/bpf/verifier.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13336,7 +13336,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
1333613336
mark_reg_known_zero(env, regs, i);
1333713337
else if (regs[i].type == SCALAR_VALUE)
1333813338
mark_reg_unknown(env, regs, i);
13339-
else if (regs[i].type == PTR_TO_MEM_OR_NULL) {
13339+
else if (base_type(regs[i].type) == PTR_TO_MEM) {
1334013340
const u32 mem_size = regs[i].mem_size;
1334113341

1334213342
mark_reg_known_zero(env, regs, i);

0 commit comments

Comments
 (0)