linux/kernel/trace
Daniel Borkmann 51e1bb9eea bpf: Add lockdown check for probe_write_user helper
Back then, commit 96ae522795 ("bpf: Add bpf_probe_write_user BPF helper
to be called in tracers") added the bpf_probe_write_user() helper in order
to allow to override user space memory. Its original goal was to have a
facility to "debug, divert, and manipulate execution of semi-cooperative
processes" under CAP_SYS_ADMIN. Write to kernel was explicitly disallowed
since it would otherwise tamper with its integrity.

One use case was shown in cf9b1199de ("samples/bpf: Add test/example of
using bpf_probe_write_user bpf helper") where the program DNATs traffic
at the time of connect(2) syscall, meaning, it rewrites the arguments to
a syscall while they're still in userspace, and before the syscall has a
chance to copy the argument into kernel space. These days we have better
mechanisms in BPF for achieving the same (e.g. for load-balancers), but
without having to write to userspace memory.

Of course the bpf_probe_write_user() helper can also be used to abuse
many other things for both good or bad purpose. Outside of BPF, there is
a similar mechanism for ptrace(2) such as PTRACE_PEEK{TEXT,DATA} and
PTRACE_POKE{TEXT,DATA}, but would likely require some more effort.
Commit 96ae522795 explicitly dedicated the helper for experimentation
purpose only. Thus, move the helper's availability behind a newly added
LOCKDOWN_BPF_WRITE_USER lockdown knob so that the helper is disabled under
the "integrity" mode. More fine-grained control can be implemented also
from LSM side with this change.

Fixes: 96ae522795 ("bpf: Add bpf_probe_write_user BPF helper to be called in tracers")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
2021-08-10 10:10:10 +02:00
..
blktrace.c
bpf_trace.c bpf: Add lockdown check for probe_write_user helper 2021-08-10 10:10:10 +02:00
bpf_trace.h
error_report-traces.c
fgraph.c
ftrace.c ftrace: Remove redundant initialization of variable ret 2021-07-23 08:46:02 -04:00
ftrace_internal.h
Kconfig trace: Add timerlat tracer 2021-06-25 19:57:24 -04:00
kprobe_event_gen_test.c
Makefile trace: Add osnoise tracer 2021-06-25 19:57:01 -04:00
power-traces.c
preemptirq_delay_test.c
ring_buffer.c tracing: Fix bug in rb_per_cpu_empty() that might cause deadloop. 2021-07-22 11:52:33 -04:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c
trace.c tracing: Fix NULL pointer dereference in start_creating 2021-07-30 18:45:11 -04:00
trace.h Tracing updates for 5.14: 2021-07-03 11:13:22 -07:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing/boot: Add per-group/all events enablement 2021-06-10 11:16:20 -04:00
trace_branch.c
trace_clock.c tracing: Do no increment trace_clock_global() by one 2021-06-18 09:10:00 -04:00
trace_dynevent.c
trace_dynevent.h
trace_entries.h trace: Add timerlat tracer 2021-06-25 19:57:24 -04:00
trace_event_perf.c
trace_events.c
trace_events_filter.c
trace_events_filter_test.h
trace_events_hist.c tracing: Reject string operand in the histogram expression 2021-08-04 17:49:26 -04:00
trace_events_inject.c
trace_events_synth.c tracing: Clean up alloc_synth_event() 2021-07-23 08:45:30 -04:00
trace_events_trigger.c tracing: Fix set_named_trigger_data() kernel-doc comment 2021-06-10 11:16:20 -04:00
trace_export.c
trace_functions.c
trace_functions_graph.c
trace_hwlat.c tracing: Quiet smp_processor_id() use in preemptable warning in hwlat 2021-08-05 09:27:31 -04:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c trace/timerlat: Fix indentation on timerlat_main() 2021-06-29 16:37:50 -04:00
trace_output.c trace: Add timerlat tracer 2021-06-25 19:57:24 -04:00
trace_output.h
trace_preemptirq.c
trace_printk.c
trace_probe.c
trace_probe.h
trace_probe_tmpl.h
trace_recursion_record.c
trace_sched_switch.c
trace_sched_wakeup.c tracing: Change variable type as bool for clean-up 2021-06-30 09:19:14 -04:00
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_synth.h tracing: Synthetic event field_pos is an index not a boolean 2021-07-23 08:43:04 -04:00
trace_syscalls.c
trace_uprobe.c
tracing_map.c
tracing_map.h