linux_dsm_epyc7002/Documentation/core-api
Daniel Borkmann b2a5212fb6 bpf: Restrict bpf_trace_printk()'s %s usage and add %pks, %pus specifier
Usage of plain %s conversion specifier in bpf_trace_printk() suffers from the
very same issue as bpf_probe_read{,str}() helpers, that is, it is broken on
archs with overlapping address ranges.

While the helpers have been addressed through work in 6ae08ae3de ("bpf: Add
probe_read_{user, kernel} and probe_read_{user, kernel}_str helpers"), we need
an option for bpf_trace_printk() as well to fix it.

Similarly as with the helpers, force users to make an explicit choice by adding
%pks and %pus specifier to bpf_trace_printk() which will then pick the corresponding
strncpy_from_unsafe*() variant to perform the access under KERNEL_DS or USER_DS.
The %pk* (kernel specifier) and %pu* (user specifier) can later also be extended
for other objects aside strings that are probed and printed under tracing, and
reused out of other facilities like bpf_seq_printf() or BTF based type printing.

Existing behavior of %s for current users is still kept working for archs where it
is not broken and therefore gated through CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE.
For archs not having this property we fall-back to pick probing under KERNEL_DS as
a sensible default.

Fixes: 8d3b7dce86 ("bpf: add support for %s specifier to bpf_trace_printk()")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Link: https://lore.kernel.org/bpf/20200515101118.6508-4-daniel@iogearbox.net
2020-05-15 08:10:36 -07:00
..
assoc_array.rst
atomic_ops.rst
boot-time-mm.rst
cachetlb.rst
circular-buffers.rst
cpu_hotplug.rst
debug-objects.rst
errseq.rst
genalloc.rst
generic-radix-tree.rst
genericirq.rst
gfp_mask-from-fs-io.rst
idr.rst
index.rst docs: move core-api/ioctl.rst to driver-api/ 2020-03-10 11:21:08 -06:00
kernel-api.rst
kobject.rst Documentation: kobject.txt has been moved to core-api/kobject.rst 2020-03-02 13:03:44 -07:00
librs.rst
local_ops.rst
memory-allocation.rst
memory-hotplug.rst
mm-api.rst mm: add pagemap.h to the fine documentation 2020-04-02 09:35:29 -07:00
packing.rst
padata.rst
pin_user_pages.rst mm: dump_page(): additional diagnostics for huge pinned pages 2020-04-02 09:35:27 -07:00
printk-formats.rst bpf: Restrict bpf_trace_printk()'s %s usage and add %pks, %pus specifier 2020-05-15 08:10:36 -07:00
protection-keys.rst
refcount-vs-atomic.rst
symbol-namespaces.rst
timekeeping.rst docs: timekeeping: Use correct prototype for deprecated functions 2020-04-15 14:48:26 -06:00
tracepoint.rst
workqueue.rst
xarray.rst