linux-kernelorg-stable/kernel/bpf
Ihor Solodrai c14bf7f873 bpf: Make reg_not_null() true for CONST_PTR_TO_MAP
[ Upstream commit 5534e58f2e ]

When reg->type is CONST_PTR_TO_MAP, it can not be null. However the
verifier explores the branches under rX == 0 in check_cond_jmp_op()
even if reg->type is CONST_PTR_TO_MAP, because it was not checked for
in reg_not_null().

Fix this by adding CONST_PTR_TO_MAP to the set of types that are
considered non nullable in reg_not_null().

An old "unpriv: cmp map pointer with zero" selftest fails with this
change, because now early out correctly triggers in
check_cond_jmp_op(), making the verification to pass.

In practice verifier may allow pointer to null comparison in unpriv,
since in many cases the relevant branch and comparison op are removed
as dead code. So change the expected test result to __success_unpriv.

Signed-off-by: Ihor Solodrai <isolodrai@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250609183024.359974-2-isolodrai@meta.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-08-20 18:30:39 +02:00
..
preload bpf/preload: Don't select USERMODE_DRIVER 2025-08-15 12:13:48 +02:00
Kconfig
Makefile
arena.c bpf: Fix softlockup in arena_map_free on 64k page kernel 2025-02-27 04:30:19 -08:00
arraymap.c bpf: Prevent tailcall infinite loop caused by freplace 2024-12-14 20:03:49 +01:00
bloom_filter.c
bpf_cgrp_storage.c bpf: Only fails the busy counter check in bpf_cgrp_storage_get if it creates storage 2025-05-02 07:59:16 +02:00
bpf_inode_storage.c
bpf_iter.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
bpf_local_storage.c bpf: bpf_local_storage: Always use bpf_mem_alloc in PREEMPT_RT 2025-02-08 09:57:29 +01:00
bpf_lru_list.c bpf: Adjust free target to avoid global starvation of LRU map 2025-07-17 18:37:22 +02:00
bpf_lru_list.h bpf: Adjust free target to avoid global starvation of LRU map 2025-07-17 18:37:22 +02:00
bpf_lsm.c bpf, lsm: Remove bpf_lsm_key_free hook 2024-10-08 12:52:40 -07:00
bpf_struct_ops.c bpf: Pass the same orig_call value to trampoline functions 2025-06-27 11:11:31 +01:00
bpf_task_storage.c
btf.c bpf: Use proper type to calculate bpf_raw_tp_null_args.mask index 2025-06-27 11:11:33 +01:00
btf_iter.c
btf_relocate.c
cgroup.c bpf: Allow pre-ordering for bpf cgroup progs 2025-05-29 11:02:17 +02:00
cgroup_iter.c
core.c bpf: Ensure RCU lock is held around bpf_prog_ksym_find 2025-08-15 12:13:41 +02:00
cpumap.c
cpumask.c
crypto.c
devmap.c bpf: fix OOB devmap writes when deleting elements 2024-12-14 20:03:30 +01:00
disasm.c
disasm.h
dispatcher.c bpf: Add kernel symbol for struct_ops trampoline 2024-12-05 14:01:57 +01:00
hashtab.c bpf: fix possible endless loop in BPF map iteration 2025-05-29 11:02:01 +02:00
helpers.c bpf: Ensure RCU lock is held around bpf_prog_ksym_find 2025-08-15 12:13:41 +02:00
inode.c bpf: Preserve param->string when parsing mount options 2024-10-22 12:56:38 -07:00
link_iter.c
local_storage.c
log.c bpf: Fix print_reg_state's constant scalar dump 2024-10-17 11:06:34 -07:00
lpm_trie.c bpf: Fix exact match conditions in trie_get_next_key() 2024-12-14 20:03:19 +01:00
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c bpf: Add bpf_mem_alloc_check_size() helper 2024-10-30 12:13:46 -07:00
mmap_unlock_work.h
mprog.c
net_namespace.c
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
relo_core.c
reuseport_array.c
ringbuf.c bpf: unify VM_WRITE vs VM_MAYWRITE use in BPF map mmaping logic 2025-02-27 04:30:18 -08:00
stackmap.c
syscall.c bpf: Allow pre-ordering for bpf cgroup progs 2025-05-29 11:02:17 +02:00
sysfs_btf.c
task_iter.c bpf: Fix iter/task tid filtering 2024-10-17 10:52:18 -07:00
tcx.c
tnum.c
token.c
trampoline.c bpf: Prevent tailcall infinite loop caused by freplace 2024-12-14 20:03:49 +01:00
verifier.c bpf: Make reg_not_null() true for CONST_PTR_TO_MAP 2025-08-20 18:30:39 +02:00