I am trying to modify the behaviour of a userspace function during runtime using ebpf uprobes. bpf_override_return
is used in kprobes to override the return value, is it possible to use it in uprobes/uretprobes?
Is it possible to use bpf_override_return in uprobes/uretprobes?
129 views Asked by imawful At
2
There are 2 answers
0
On
There is another userspace eBPF runtime, https://github.com/eunomia-bpf/bpftime which can be compatible with kernel eBPF uprobe and supports override userspace functions and this helper. Maybe you can have a try?
See the examples in https://github.com/eunomia-bpf/bpftime/tree/master/example/error-inject (It's experimental, though)
uprobes share the BPF infrastructure of kprobes so yes, you should be able to call
bpf_override_return
from uprobe BPF programs. Note you'll needCONFIG_BPF_KPROBE_OVERRIDE
in your kernel config.The bcc project has a list of which helpers are allowed from which program types at https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md.
To check yourself which program type allow for a given helper, you can run the following on the kernel sources:
Here we see that
bpf_override_return
can be called from kprobe programs only.