linux-xiaomi-chiron/tools/include/uapi/linux
Daniel Borkmann 6ae08ae3de bpf: Add probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers
The current bpf_probe_read() and bpf_probe_read_str() helpers are broken
in that they assume they can be used for probing memory access for kernel
space addresses /as well as/ user space addresses.

However, plain use of probe_kernel_read() for both cases will attempt to
always access kernel space address space given access is performed under
KERNEL_DS and some archs in-fact have overlapping address spaces where a
kernel pointer and user pointer would have the /same/ address value and
therefore accessing application memory via bpf_probe_read{,_str}() would
read garbage values.

Lets fix BPF side by making use of recently added 3d7081822f ("uaccess:
Add non-pagefault user-space read functions"). Unfortunately, the only way
to fix this status quo is to add dedicated bpf_probe_read_{user,kernel}()
and bpf_probe_read_{user,kernel}_str() helpers. The bpf_probe_read{,_str}()
helpers are kept as-is to retain their current behavior.

The two *_user() variants attempt the access always under USER_DS set, the
two *_kernel() variants will -EFAULT when accessing user memory if the
underlying architecture has non-overlapping address ranges, also avoiding
throwing the kernel warning via 00c42373d3 ("x86-64: add warning for
non-canonical user access address dereferences").

Fixes: a5e8c07059 ("bpf: add bpf_probe_read_str helper")
Fixes: 2541517c32 ("tracing, perf: Implement BPF programs attached to kprobes")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/796ee46e948bc808d54891a1108435f8652c6ca4.1572649915.git.daniel@iogearbox.net
2019-11-02 12:39:12 -07:00
..
tc_act
bpf.h bpf: Add probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers 2019-11-02 12:39:12 -07:00
bpf_common.h
bpf_perf_event.h
btf.h
const.h tools headers: Grab copy of linux/const.h, needed by linux/bits.h 2019-08-20 12:08:23 -03:00
erspan.h
ethtool.h
fadvise.h
fcntl.h
fs.h tools headers uapi: Sync linux/fs.h with the kernel sources 2019-09-30 17:29:22 -03:00
fscrypt.h tools headers uapi: Sync linux/fs.h with the kernel sources 2019-09-30 17:29:22 -03:00
hw_breakpoint.h
if_link.h tools: Sync if_link.h 2019-10-21 14:49:12 +02:00
if_tun.h
if_xdp.h libbpf: add flags to umem config 2019-08-31 01:08:26 +02:00
in.h
kcmp.h
kvm.h tools headers kvm: Sync kvm headers with the kernel sources 2019-09-30 17:29:30 -03:00
lirc.h
mman.h
mount.h
netlink.h
perf_event.h perf tools: Add aux_output attribute flag 2019-08-14 10:59:59 -03:00
pkt_cls.h
pkt_sched.h
prctl.h tools headers uapi: Sync prctl.h with the kernel sources 2019-09-20 14:59:05 -03:00
sched.h
seg6.h
seg6_local.h
stat.h
tls.h
usbdevice_fs.h tools headers uapi: Sync linux/usbdevice_fs.h with the kernel sources 2019-09-30 17:29:02 -03:00
vhost.h