Skip to content

Commit cf9f2f8

Browse files
haoluo1022Alexei Starovoitov
authored and
Alexei Starovoitov
committed
bpf: Convert PTR_TO_MEM_OR_NULL to composable types.
Remove PTR_TO_MEM_OR_NULL and replace it with PTR_TO_MEM combined with flag PTR_MAYBE_NULL. Signed-off-by: Hao Luo <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 20b2aff commit cf9f2f8

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

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
@@ -5859,7 +5859,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
58595859
return -EINVAL;
58605860
}
58615861

5862-
reg->type = PTR_TO_MEM_OR_NULL;
5862+
reg->type = PTR_TO_MEM | PTR_MAYBE_NULL;
58635863
reg->id = ++env->id_gen;
58645864

58655865
continue;

kernel/bpf/verifier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13578,7 +13578,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
1357813578
mark_reg_known_zero(env, regs, i);
1357913579
else if (regs[i].type == SCALAR_VALUE)
1358013580
mark_reg_unknown(env, regs, i);
13581-
else if (regs[i].type == PTR_TO_MEM_OR_NULL) {
13581+
else if (base_type(regs[i].type) == PTR_TO_MEM) {
1358213582
const u32 mem_size = regs[i].mem_size;
1358313583

1358413584
mark_reg_known_zero(env, regs, i);

0 commit comments

Comments
 (0)