exynos-linux-stable/kernel/bpf
Paul Chaignon 83d94de3d6
bpf: allow map helpers access to map values directly
Helpers that expect ARG_PTR_TO_MAP_KEY and ARG_PTR_TO_MAP_VALUE can only
access stack and packet memory.  Allow these helpers to directly access
map values by passing registers of type PTR_TO_MAP_VALUE.

This change removes the need for an extra copy to the stack when using a
map value to perform a second map lookup, as in the following:

struct bpf_map_def SEC("maps") infobyreq = {
    .type = BPF_MAP_TYPE_HASHMAP,
    .key_size = sizeof(struct request *),
    .value_size = sizeof(struct info_t),
    .max_entries = 1024,
};
struct bpf_map_def SEC("maps") counts = {
    .type = BPF_MAP_TYPE_HASHMAP,
    .key_size = sizeof(struct info_t),
    .value_size = sizeof(u64),
    .max_entries = 1024,
};
SEC("kprobe/blk_account_io_start")
int bpf_blk_account_io_start(struct pt_regs *ctx)
{
    struct info_t *info = bpf_map_lookup_elem(&infobyreq, &ctx->di);
    u64 *count = bpf_map_lookup_elem(&counts, info);
    (*count)++;
}

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2024-09-25 16:54:47 +03:00
..
arraymap.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
bpf_lru_list.c bpf_lru_list: Read double-checked variable once without lock 2024-09-25 16:54:38 +03:00
bpf_lru_list.h bpf: Add percpu LRU list 2024-09-25 16:54:37 +03:00
btf.c bpf: btf: fix truncated last_member_type_id in btf_struct_resolve 2024-09-25 16:54:45 +03:00
cgroup.c BACKPORT: bpf: Hooks for sys_bind 2024-09-25 16:54:46 +03:00
core.c bpf: Fix incompatible function pointer 2024-09-25 16:54:46 +03:00
devmap.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
hashtab.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
helpers.c BACKPORT: bpf: add bpf_ktime_get_boot_ns() 2024-09-25 16:54:45 +03:00
inode.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
lpm_trie.c bpf, lpm: Fix check prefixlen before walking trie 2024-09-25 16:54:46 +03:00
Makefile BACKPORT: bpf: offload: add infrastructure for loading programs for a specific netdev 2024-09-25 16:54:45 +03:00
map_in_map.c bpf: Add array of maps support 2024-09-25 16:54:38 +03:00
map_in_map.h bpf: Add array of maps support 2024-09-25 16:54:38 +03:00
offload.c bpf: offload: rename the ifindex field 2024-09-25 16:54:45 +03:00
percpu_freelist.c bpf: fix lockdep splat 2017-12-14 09:28:23 +01:00
percpu_freelist.h bpf: introduce percpu_freelist 2016-03-08 15:28:31 -05:00
sockmap.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
stackmap.c BACKPORT: bpf: Add file mode configuration into bpf maps 2024-09-25 16:54:43 +03:00
syscall.c kernel: bpf: syscall: replace __vmalloc_node_flags_caller with __vmalloc_node_flags 2024-09-25 16:54:47 +03:00
verifier.c bpf: allow map helpers access to map values directly 2024-09-25 16:54:47 +03:00