linux-stable/kernel/trace
Yonghong Song b36e62eb85 bpf: Use strncpy_from_unsafe_strict() in bpf_seq_printf() helper
In bpf_seq_printf() helper, when user specified a "%s" in the
format string, strncpy_from_unsafe() is used to read the actual string
to a buffer. The string could be a format string or a string in
the kernel data structure. It is really unlikely that the string
will reside in the user memory.

This is different from Commit b2a5212fb6 ("bpf: Restrict bpf_trace_printk()'s %s
usage and add %pks, %pus specifier") which still used
strncpy_from_unsafe() for "%s" to preserve the old behavior.

If in the future, bpf_seq_printf() indeed needs to read user
memory, we can implement "%pus" format string.

Based on discussion in [1], if the intent is to read kernel memory,
strncpy_from_unsafe_strict() should be used. So this patch
changed to use strncpy_from_unsafe_strict().

[1]: https://lore.kernel.org/bpf/20200521152301.2587579-1-hch@lst.de/T/

Fixes: 492e639f0c ("bpf: Add bpf_seq_printf and bpf_seq_write helpers")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/bpf/20200529004810.3352219-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2020-06-01 14:48:31 -07:00
..
blktrace.c blktrace: fix dereference after null check 2020-03-05 13:42:40 -07:00
bpf_trace.c bpf: Use strncpy_from_unsafe_strict() in bpf_seq_printf() helper 2020-06-01 14:48:31 -07:00
fgraph.c
ftrace.c ftrace: Fix memory leak caused by not freeing entry in unregister_ftrace_direct() 2020-04-22 22:04:27 -04:00
ftrace_internal.h x86/ftrace: Have ftrace trampolines turn read-only at the end of system boot up 2020-05-12 18:24:34 -04:00
Kconfig Stop the ad-hoc games with -Wno-maybe-initialized 2020-05-09 13:57:10 -07:00
kprobe_event_gen_test.c
Makefile
power-traces.c
preemptirq_delay_test.c tracing: Wait for preempt irq delay thread to execute 2020-05-11 17:00:34 -04:00
ring_buffer.c ring-buffer: Remove all BUG() calls 2020-05-14 08:51:02 -04:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c tracing: Have synthetic event test use raw_smp_processor_id() 2020-02-20 17:43:41 -05:00
trace.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-05-15 13:48:59 -07:00
trace.h tracing: Create set_event_notrace_pid to not trace tasks 2020-03-27 16:39:02 -04:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing/boottime: Fix kprobe event API usage 2020-05-06 09:04:11 -04:00
trace_branch.c
trace_clock.c
trace_dynevent.c
trace_dynevent.h
trace_entries.h tracing: Have hwlat ts be first instance and record count of instances 2020-03-03 17:33:43 -05:00
trace_event_perf.c
trace_events.c tracing: Create set_event_notrace_pid to not trace tasks 2020-03-27 16:39:02 -04:00
trace_events_filter.c
trace_events_filter_test.h
trace_events_hist.c tracing: Fix memory leaks in trace_events_hist.c 2020-04-22 21:24:00 -04:00
trace_events_inject.c
trace_events_trigger.c tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation 2020-04-14 22:02:10 -04:00
trace_export.c
trace_functions.c
trace_functions_graph.c ring-buffer: Rename ring_buffer_read() to read_buffer_iter_advance() 2020-03-19 19:11:19 -04:00
trace_hwlat.c tracing: Have hwlat ts be first instance and record count of instances 2020-03-03 17:33:43 -05:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c tracing/kprobes: Reject new event if loc is NULL 2020-05-06 09:04:11 -04:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Save off entry when peeking at next entry 2020-03-19 17:48:36 -04:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe.c
trace_probe.h
trace_probe_tmpl.h
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_syscalls.c
trace_uprobe.c bpf: disable preemption for bpf progs attached to uprobe 2020-02-24 16:17:14 -08:00
tracing_map.c tracing: Convert local functions in tracing_map.c to static 2020-04-22 22:07:26 -04:00
tracing_map.h