Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Officeyutong opened this issue Feb 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Officeyutong
Copy link
Contributor

Officeyutong commented Feb 28, 2024

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:

  • Hook function open and read, so that make libbpf think the file exists
  • Put that file in docker image to trick libbpf that the file exists. Possible problem: Do we need to mount /sys from the host so that we can use syscall tracepoint?
@Officeyutong Officeyutong added the enhancement New feature or request label Feb 28, 2024
@yunwei37 yunwei37 changed the title [FEATURE] Support bpftime uprobe on kernel that doesn't support uprobe [FEATURE] Support read /sys/bus/event_source/devices/uprobe/type on old kernel versions Feb 28, 2024
@yunwei37 yunwei37 added bug Something isn't working help wanted Extra attention is needed and removed enhancement New feature or request labels Feb 28, 2024
@yunwei37
Copy link
Member

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
Copy link
Member

yunwei37 commented Mar 6, 2024

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
Copy link
Member

yunwei37 commented Mar 6, 2024

Related to #145

@yunwei37 yunwei37 added the good first issue Good for newcomers label Mar 6, 2024
@yunwei37
Copy link
Member

yunwei37 commented Mar 6, 2024

@zhangzihengya
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants