libbpf: Add user-space variants of BPF_CORE_READ() family of macros
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 18 Dec 2020 23:56:12 +0000 (15:56 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 8 Jan 2021 21:39:24 +0000 (13:39 -0800)
commit792001f4f7aa036b1f1c1ed7bce44bb49126208a
tree95d6e3385c55e51fba29224e53d2c4f6cefbc3ab
parent833d22f2f922bbee6430e558417af060db6bbe9c
libbpf: Add user-space variants of BPF_CORE_READ() family of macros

Add BPF_CORE_READ_USER(), BPF_CORE_READ_USER_STR() and their _INTO()
variations to allow reading CO-RE-relocatable kernel data structures from the
user-space. One of such cases is reading input arguments of syscalls, while
reaping the benefits of CO-RE relocations w.r.t. handling 32/64 bit
conversions and handling missing/new fields in UAPI data structs.

Suggested-by: Gilad Reti <gilad.reti@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20201218235614.2284956-2-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/bpf_core_read.h