mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 18:13:04 +00:00
737d0646a8
Add high-level API wrappers for most common and typical BPF map operations that works directly on instances of struct bpf_map * (so you don't have to call bpf_map__fd()) and validate key/value size expectations. These helpers require users to specify key (and value, where appropriate) sizes when performing lookup/update/delete/etc. This forces user to actually think and validate (for themselves) those. This is a good thing as user is expected by kernel to implicitly provide correct key/value buffer sizes and kernel will just read/write necessary amount of data. If it so happens that user doesn't set up buffers correctly (which bit people for per-CPU maps especially) kernel either randomly overwrites stack data or return -EFAULT, depending on user's luck and circumstances. These high-level APIs are meant to prevent such unpleasant and hard to debug bugs. This patch also adds bpf_map_delete_elem_flags() low-level API and requires passing flags to bpf_map__delete_elem() API for consistency across all similar APIs, even though currently kernel doesn't expect any extra flags for BPF_MAP_DELETE_ELEM operation. List of map operations that get these high-level APIs: - bpf_map_lookup_elem; - bpf_map_update_elem; - bpf_map_delete_elem; - bpf_map_lookup_and_delete_elem; - bpf_map_get_next_key. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20220512220713.2617964-1-andrii@kernel.org |
||
---|---|---|
.. | ||
.gitignore | ||
bpf_core_read.h | ||
bpf_endian.h | ||
bpf_gen_internal.h | ||
bpf_helpers.h | ||
bpf_prog_linfo.c | ||
bpf_tracing.h | ||
bpf.c | ||
bpf.h | ||
btf_dump.c | ||
btf.c | ||
btf.h | ||
Build | ||
gen_loader.c | ||
hashmap.c | ||
hashmap.h | ||
libbpf_common.h | ||
libbpf_errno.c | ||
libbpf_internal.h | ||
libbpf_legacy.h | ||
libbpf_probes.c | ||
libbpf_version.h | ||
libbpf.c | ||
libbpf.h | ||
libbpf.map | ||
libbpf.pc.template | ||
linker.c | ||
Makefile | ||
netlink.c | ||
nlattr.c | ||
nlattr.h | ||
relo_core.c | ||
relo_core.h | ||
ringbuf.c | ||
skel_internal.h | ||
str_error.c | ||
str_error.h | ||
strset.c | ||
strset.h | ||
usdt.bpf.h | ||
usdt.c | ||
xsk.c | ||
xsk.h |