OrangePi_CM5/kernel/bpf
Youlin Li cedd4f01f6 bpf: Fix wrong reg type conversion in release_reference()
[ Upstream commit f1db20814af532f85e091231223e5e4818e8464b ]

Some helper functions will allocate memory. To avoid memory leaks, the
verifier requires the eBPF program to release these memories by calling
the corresponding helper functions.

When a resource is released, all pointer registers corresponding to the
resource should be invalidated. The verifier use release_references() to
do this job, by apply  __mark_reg_unknown() to each relevant register.

It will give these registers the type of SCALAR_VALUE. A register that
will contain a pointer value at runtime, but of type SCALAR_VALUE, which
may allow the unprivileged user to get a kernel pointer by storing this
register into a map.

Using __mark_reg_not_init() while NOT allow_ptr_leaks can mitigate this
problem.

Fixes: fd978bf7fd ("bpf: Add reference tracking to verifier")
Signed-off-by: Youlin Li <liulin063@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221103093440.3161-1-liulin063@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 09:57:09 +01:00
..
preload
…
Makefile
…
arraymap.c bpf: Acquire map uref in .init_seq_private for array map iterator 2022-08-25 11:37:55 +02:00
bpf_inode_storage.c
…
bpf_iter.c
…
bpf_local_storage.c
…
bpf_lru_list.c
…
bpf_lru_list.h
…
bpf_lsm.c
…
bpf_struct_ops.c
…
bpf_struct_ops_types.h
…
btf.c bpf: btf: fix truncated last_member_type_id in btf_struct_resolve 2022-10-26 13:25:20 +02:00
cgroup.c bpf, cgroup: Fix kernel BUG in purge_effective_progs 2022-09-08 11:11:36 +02:00
core.c bpf: Make sure mac_header was set before using it 2022-07-29 17:19:23 +02:00
cpumap.c
…
devmap.c bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc 2021-12-17 10:14:41 +01:00
disasm.c
…
disasm.h
…
dispatcher.c
…
hashtab.c bpf: Acquire map uref in .init_seq_private for hash map iterator 2022-08-25 11:37:55 +02:00
helpers.c
…
inode.c
…
local_storage.c
…
lpm_trie.c
…
map_in_map.c
…
map_in_map.h
…
map_iter.c
…
net_namespace.c
…
offload.c
…
percpu_freelist.c
…
percpu_freelist.h
…
prog_iter.c
…
queue_stack_maps.c
…
reuseport_array.c
…
ringbuf.c bpf: Use VM_MAP instead of VM_ALLOC for ringbuf 2022-02-08 18:30:39 +01:00
stackmap.c bpf: Fix incorrect memory charge cost calculation in stack_map_alloc() 2022-06-22 14:13:12 +02:00
syscall.c bpf: Ensure correct locking around vulnerable function find_vpid() 2022-10-26 13:25:21 +02:00
sysfs_btf.c
…
task_iter.c
…
tnum.c
…
trampoline.c bpf: Fix potential array overflow in bpf_trampoline_get_progs() 2022-06-06 08:42:45 +02:00
verifier.c bpf: Fix wrong reg type conversion in release_reference() 2022-11-16 09:57:09 +01:00