Skip to content

Commit cbad29d

Browse files
bpf: Convert PTR_TO_MEM_OR_NULL to composable types.
jira VULN-140 pre-cve CVE-2022-23222 commit-author Hao Luo <[email protected]> commit cf9f2f8 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] (cherry picked from commit cf9f2f8) Signed-off-by: Pratham Patel <[email protected]>
1 parent 9d2bd80 commit cbad29d

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
@@ -485,7 +485,6 @@ enum bpf_reg_type {
485485
PTR_TO_SOCK_COMMON_OR_NULL = PTR_MAYBE_NULL | PTR_TO_SOCK_COMMON,
486486
PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK,
487487
PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID,
488-
PTR_TO_MEM_OR_NULL = PTR_MAYBE_NULL | PTR_TO_MEM,
489488

490489
/* This must be the last entry. Its purpose is to ensure the enum is
491490
* 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
@@ -5667,7 +5667,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
56675667
return -EINVAL;
56685668
}
56695669

5670-
reg->type = PTR_TO_MEM_OR_NULL;
5670+
reg->type = PTR_TO_MEM | PTR_MAYBE_NULL;
56715671
reg->id = ++env->id_gen;
56725672

56735673
continue;

kernel/bpf/verifier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12703,7 +12703,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
1270312703
mark_reg_known_zero(env, regs, i);
1270412704
else if (regs[i].type == SCALAR_VALUE)
1270512705
mark_reg_unknown(env, regs, i);
12706-
else if (regs[i].type == PTR_TO_MEM_OR_NULL) {
12706+
else if (base_type(regs[i].type) == PTR_TO_MEM) {
1270712707
const u32 mem_size = regs[i].mem_size;
1270812708

1270912709
mark_reg_known_zero(env, regs, i);

0 commit comments

Comments
 (0)