kernel_optimize_test/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 ia64/tlb: Eradicate tlb_migrate_finish() callback 2019-04-03 10:33:04 +02:00
circular-buffers.rst doc: Remove ".vnet" from paulmck email addresses 2019-05-28 09:02:57 -07:00
cpu_hotplug.rst
debug-objects.rst
errseq.rst
genalloc.rst lib/genalloc.c: rename addr_in_gen_pool to gen_pool_has_addr 2019-12-04 19:44:13 -08:00
generic-radix-tree.rst generic radix trees 2019-03-12 10:04:02 -07:00
genericirq.rst docs: Add request_irq() documentation 2019-11-18 12:40:59 -07:00
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 docs/core-api: Remove possibly confusing sub-headings from Bit Operations 2019-12-04 21:20:28 +11:00
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 docs/core-api: memory-allocation: mention size helpers 2019-10-29 04:45:40 -06:00
memory-hotplug.rst
mm-api.rst mm: add pagemap.h to the fine documentation 2020-04-02 09:35:29 -07:00
packing.rst docs: packing: move it to core-api book and adjust markups 2019-07-31 13:30:01 -06:00
padata.rst padata: update documentation 2019-12-11 16:37:02 +08:00
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 docs: move protection-keys.rst to the core-api book 2019-06-08 13:42:12 -06:00
refcount-vs-atomic.rst docs: remove :c:func: from refcount-vs-atomic.rst 2019-10-07 09:08:56 -06:00
symbol-namespaces.rst scripts/nsdeps: support nsdeps for external module builds 2019-11-11 20:10:01 +09:00
timekeeping.rst docs: timekeeping: Use correct prototype for deprecated functions 2020-04-15 14:48:26 -06:00
tracepoint.rst
workqueue.rst
xarray.rst XArray: Add xa_for_each_range 2020-01-17 22:33:37 -05:00