android_kernel_motorola_sm6375/kernel/bpf
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Lorenz Bauer a7f9cb8aa6
UPSTREAM: bpf: sockmap: Allow update from BPF
Allow calling bpf_map_update_elem on sockmap and sockhash from a BPF
context. The synchronization required for this is a bit fiddly: we
need to prevent the socket from changing its state while we add it
to the sockmap, since we rely on getting a callback via
sk_prot->unhash. However, we can't just lock_sock like in
sock_map_sk_acquire because that might sleep. So instead we disable
softirq processing and use bh_lock_sock to prevent further
modification.

Yet, this is still not enough. BPF can be called in contexts where
the current CPU might have locked a socket. If the BPF can get
a hold of such a socket, inserting it into a sockmap would lead to
a deadlock. One straight forward example are sock_ops programs that
have ctx->sk, but the same problem exists for kprobes, etc.
We deal with this by allowing sockmap updates only from known safe
contexts. Improper usage is rejected by the verifier.

I've audited the enabled contexts to make sure they can't run in
a locked context. It's possible that CGROUP_SKB and others are
safe as well, but the auditing here is much more difficult. In
any case, we can extend the safe contexts when the need arises.

Change-Id: I027ee5ca527c8be7ca29d5330e3a8a1f990c0554
Signed-off-by: Lorenz Bauer <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Yonghong Song <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
2026-01-14 18:12:17 -08:00
..
preload UPSTREAM: bpf: Add kernel module with user mode driver that populates bpffs. 2026-01-14 18:12:16 -08:00
arraymap.c UPSTREAM: bpf: Implement bpf iterator for array maps 2026-01-14 18:12:07 -08:00
bpf_iter.c UPSTREAM: bpf: Implement link_query for bpf iterators 2026-01-14 18:12:16 -08:00
bpf_lru_list.c
bpf_lru_list.h UPSTREAM: bpf: Fix a typo "inacitve" -> "inactive" 2025-12-23 13:36:12 -08:00
bpf_lsm.c UPSTREAM: bpf: Use tracing helpers for lsm programs 2026-01-14 17:48:07 -08:00
bpf_struct_ops.c UPSTREAM: bpf: Set map_btf_{name, id} for all map types 2026-01-14 17:50:46 -08:00
bpf_struct_ops_types.h
btf.c UPSTREAM: bpf: Support readonly/readwrite buffers in verifier 2026-01-14 18:12:07 -08:00
cgroup.c UPSTREAM: bpf: Add support for forced LINK_DETACH command 2026-01-14 18:12:12 -08:00
core.c UPSTREAM: bpf: Delete repeated words in comments 2026-01-14 18:12:12 -08:00
cpumap.c UPSTREAM: bpf: cpumap: Fix possible rcpu kthread hung 2026-01-14 18:12:05 -08:00
devmap.c UPSTREAM: bpf: Set map_btf_{name, id} for all map types 2026-01-14 17:50:46 -08:00
disasm.c
disasm.h
dispatcher.c UPSTREAM: bpf: Remove bpf_image tree 2025-12-23 13:36:07 -08:00
hashtab.c UPSTREAM: bpf: Implement bpf iterator for hash maps 2026-01-14 18:12:07 -08:00
helpers.c UPSTREAM: bpf: Implement BPF ring buffer and verifier support for it 2026-01-14 17:48:05 -08:00
inode.c UPSTREAM: bpf: Add kernel module with user mode driver that populates bpffs. 2026-01-14 18:12:16 -08:00
local_storage.c UPSTREAM: bpf/local_storage: Fix build without CONFIG_CGROUP 2026-01-14 18:12:08 -08:00
lpm_trie.c UPSTREAM: bpf: Remove redundant synchronize_rcu. 2026-01-14 18:12:00 -08:00
Makefile UPSTREAM: bpf: Add kernel module with user mode driver that populates bpffs. 2026-01-14 18:12:16 -08:00
map_in_map.c BACKPORT: bpf: Implement CAP_BPF 2026-01-14 17:44:17 -08:00
map_in_map.h
map_iter.c UPSTREAM: bpf: Implement link_query callbacks in map element iterators 2026-01-14 18:12:16 -08:00
net_namespace.c UPSTREAM: bpf: Add support for forced LINK_DETACH command 2026-01-14 18:12:12 -08:00
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c UPSTREAM: bpf: Refactor bpf_iter_reg to have separate seq_info member 2026-01-14 18:12:07 -08:00
queue_stack_maps.c UPSTREAM: bpf: Remove redundant synchronize_rcu. 2026-01-14 18:12:00 -08:00
reuseport_array.c UPSTREAM: bpf: net: Avoid incorrect bpf_sk_reuseport_detach call 2026-01-14 18:12:02 -08:00
ringbuf.c UPSTREAM: bpf: Remove redundant synchronize_rcu. 2026-01-14 18:12:00 -08:00
stackmap.c UPSTREAM: bpf: Iterate through all PT_NOTE sections when looking for build id 2026-01-14 18:12:13 -08:00
syscall.c UPSTREAM: bpf: sockmap: Call sock_map_update_elem directly 2026-01-14 18:12:16 -08:00
sysfs_btf.c
task_iter.c UPSTREAM: bpf: Avoid visit same object multiple times 2026-01-14 18:12:13 -08:00
tnum.c BACKPORT: bpf: Verifier, do explicit ALU32 bounds tracking 2025-12-23 13:36:11 -08:00
trampoline.c UPSTREAM: bpf: lsm: Implement attach, detach and execution 2025-12-23 13:36:10 -08:00
verifier.c UPSTREAM: bpf: sockmap: Allow update from BPF 2026-01-14 18:12:17 -08:00