Skip to content

Commit ae76ec7

Browse files
committed
bpf: Convert PTR_TO_MEM_OR_NULL to composable types.
jira VULN-136 cve-pre CVE-2022-0500 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: Brett Mastbergen <[email protected]>
1 parent 5e05f02 commit ae76ec7

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
@@ -487,7 +487,6 @@ enum bpf_reg_type {
487487
PTR_TO_SOCK_COMMON_OR_NULL = PTR_MAYBE_NULL | PTR_TO_SOCK_COMMON,
488488
PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK,
489489
PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID,
490-
PTR_TO_MEM_OR_NULL = PTR_MAYBE_NULL | PTR_TO_MEM,
491490

492491
/* This must be the last entry. Its purpose is to ensure the enum is
493492
* 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
@@ -12740,7 +12740,7 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
1274012740
mark_reg_known_zero(env, regs, i);
1274112741
else if (regs[i].type == SCALAR_VALUE)
1274212742
mark_reg_unknown(env, regs, i);
12743-
else if (regs[i].type == PTR_TO_MEM_OR_NULL) {
12743+
else if (base_type(regs[i].type) == PTR_TO_MEM) {
1274412744
const u32 mem_size = regs[i].mem_size;
1274512745

1274612746
mark_reg_known_zero(env, regs, i);

0 commit comments

Comments
 (0)