eunomia-bpf / bpftime

Userspace eBPF runtime for Observability, Network & General Extensions Framework
https://eunomia.dev/bpftime/
MIT License
834 stars 78 forks source link

[FEATURE] Support read `/sys/bus/event_source/devices/uprobe/type` on old kernel versions #239

Open Officeyutong opened 9 months ago

Officeyutong commented 9 months ago

Libbpf will try to read /sys/bus/event_source/devices/uprobe/type when creating uprobe perf event. This file doesn't exist on kernel that doesn't support uprobe. But since userspace uprobe doesn't rely on kernel features, we should make it support such kernel versions.

Possible ways:

yunwei37 commented 9 months ago

In docker, you can mount a regular dir into /sys/bus/event_source/devices/uprobe/ fc5ea63646aace06117ae7acfe40a45

So in order to run bpftime on old kernel version, you can simply copy the content of /sys/bus/event_source/devices/uprobe/ on new kernel, put it on old kernel, and mount it with docker.

yunwei37 commented 8 months ago

Another approach is hook open function with LD_PRELOAD in syscall-server.so, and prepare a directory with the same content as /sys/bus/event_source/devices/uprobe in ~/.bpftime/event_source/devices/uprobe. When the libbpf tries to read something in /sys/bus/event_source/devices/uprobe but it's not exists, we can change the open file to make it actually read contents in ~/.bpftime/event_source/devices/uprobe.

yunwei37 commented 8 months ago

Related to #145

yunwei37 commented 8 months ago

Please modify code in https://github.com/eunomia-bpf/bpftime/tree/master/runtime/syscall-server

zhangzihengya commented 8 months ago

hi @Officeyutong @yunwei37 would like to take a crack at this, could you please assign this to me