diff options
| author | Paul Chaignon <paul.chaignon@gmail.com> | 2023-10-02 11:56:01 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-10-16 15:57:22 +0000 |
| commit | 8e4e71ae23a4d19c024f959445d207d06a795f56 (patch) | |
| tree | 2a51d5fd0bfb64903b689c07a8d299dbe9f9d356 /sys/linux/test | |
| parent | ff4096d35b1c40d7e6b5d1aea4741ab2bea0297d (diff) | |
sys/linux: describe full call to bpf_trace_printk helper
This commit describes the full snippet of BPF bytecode necessary to
successfully call the bpf_trace_printk helper.
That helper has the following prototype:
long bpf_trace_printk(const char *fmt, u32 fmt_size, ...)
We thus need to initialize the fmt string on the stack, then prepare the
arguments (pointer to the stack & size), before actually calling the
helper.
To that end, we rely on previously defined templates to express the
specific instructions we need (e.g., init register with imm, perform ALU
operation on register with imm).
The corresponding eBPF bytecode is kept in comment as that is much
easier to parse for anyone familiar with the bytecode.
In addition to the test case introduced in the next commit, this new
description was tested by focusing fuzzing on bpf_trace_printk. That is,
a new syscall description PROG_LOAD_FOCUS was added to cover only
programs with bpf_trace_printk. Syzkaller was then executed on 16 VMs (2
logical cores each) with only the bpf$PROG_LOAD_FOCUS and
bpf$BPF_PROG_TEST_RUN syscalls enabled. It was able to reach the
definition of this helper [1] within a few minutes.
1 - https://github.com/torvalds/linux/blob/v6.5/kernel/trace/bpf_trace.c#L375
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'sys/linux/test')
0 files changed, 0 insertions, 0 deletions
