This patch series contains two patches that add support for a probe_write
helper to BPF programs. This allows them to manipulate user memory during
the course of tracing. The second patch in the series has an example that
uses it, in one the intended ways to divert execution.

Thanks to Alexei Starovoitov, and Daniel Borkmann for review, I've made
changes based on their recommendations.

This helper should be considered experimental, so we print a warning
to dmesg when it is first invoked. Subsequent invocations print the
command and pid

---
v1->v2: restrict writing to user space, as opposed to globally
v2->v3: Fixed formatting issues
v3->v4: Rename copy_to_user -> bpf_probe_write
        Simplify checking of whether or not it's safe to write
        Add warnings to dmesg
v4->v5: Raise warning level
        Cleanup location of warning code
        Make test fail when helper is broken

Sargun Dhillon (2):
  bpf: Add bpf_probe_write_user BPF helper to be called in tracers
  samples/bpf: Add test/example of using bpf_probe_write_user bpf helper

 include/uapi/linux/bpf.h                 | 10 ++++
 kernel/trace/bpf_trace.c                 | 48 ++++++++++++++++++++
 samples/bpf/Makefile                     |  4 ++
 samples/bpf/bpf_helpers.h                |  2 +
 samples/bpf/test_probe_write_user_kern.c | 52 +++++++++++++++++++++
 samples/bpf/test_probe_write_user_user.c | 78 ++++++++++++++++++++++++++++++++
 6 files changed, 194 insertions(+)
 create mode 100644 samples/bpf/test_probe_write_user_kern.c
 create mode 100644 samples/bpf/test_probe_write_user_user.c

-- 
2.7.4

Reply via email to