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

ply 'kprobe:do_sys_open { printf("%v(%v): %s\n", comm, uid, str(arg1)); }' can not print filename #87

Open
wanlon opened this issue Jun 6, 2023 · 4 comments

Comments

@wanlon
Copy link

wanlon commented Jun 6, 2023

hi, I can not print filename in my x86 arch system
image

@ismhong
Copy link

ismhong commented Jun 6, 2023

This issue should be related to comment 17864b9 ("ply: Use new read_kernel variants").

According to the definition of do_sys_open below, the argument *filename is declared with attribute __user, so we need to use BPF helper bpf_probe_read_user() / bpf_probe_read_str().

long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode);

For local test, you can just revert the commit 17864b9 ("ply: Use new read_kernel variants"), and it should work correctly.

# sudo ./ply 'kprobe:do_sys_open* { printf("%v(%v): %s\n", comm, uid, str(arg1)); }'
device poll    (1000): /dev/bus/usb
device poll    (1000): /dev/bus/usb/002
device poll    (1000): /dev/bus/usb/002/002
device poll    (1000): /dev/bus/usb/002/001
device poll    (1000): /dev/bus/usb/001
device poll    (1000): /dev/bus/usb/001/003

The solution should be something done in bpftrace below, adding syntax to let user specify the reading source from user/kernel space.

Hi @wkz , could you please give some advice on this? Thank you. :)

This issue should be similar with #85.

@wanlon
Copy link
Author

wanlon commented Jun 7, 2023

This error not happans in arm64 arch

@wanlon
Copy link
Author

wanlon commented Jun 7, 2023

hi,I tried again according to your instructions and solved the problem I mentioned

@stschake
Copy link

stschake commented Oct 4, 2023

I've been working on bringing back userland probes and as part of that added a "uptr" mechanism:

stschake@31d75fd

(sorry, this commit is not all of it - also needs the prev commit adding the "user" hint)

This allows for a probe like 'kprobe:do_sys_open { printf("%v(%v): %s\n", comm, uid, str(uptr(arg1))); }' and will correctly print the filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants