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 request: reads from inotify file descriptors should decode the struct #199

Open
ericonr opened this issue Oct 7, 2021 · 4 comments

Comments

@ericonr
Copy link

ericonr commented Oct 7, 2021

I'm not sure if this is possible with the current infrastructure, and I only looked through the strace code base briefly... But the idea would be to somehow register a file descriptor as having been created by inotify_init/inotify_init1, and then reads from this file descriptor would show the decoded struct inotify_event instead of interpreting it as a string.

@ldv-alt
Copy link
Member

ldv-alt commented Oct 7, 2021 via email

@ericonr
Copy link
Author

ericonr commented Oct 7, 2021

Oh, that sounds great! I will try my hand at implementing it, then. Thanks for the quick answer.

@masatake
Copy link
Contributor

masatake commented Oct 7, 2021

Interesting.

I studied how to store information in /proc/$pid/fdinfo/$fd to the private fields of tcb for decoding ioctl about vfio. My code requires a change to the Linux kernel. So I didn't submit the result of the study to the strace mailing list.
But I wonder my study can help you implement what you want.

When decoding the buffer filled by read(2), you may want to know whether the fd
passed to read(2) is returned from inotify_init or not.
The hint is in the implementation of -y option.
If strace is run with -y option, the information of file descriptor is printed like:

read(3<inotify>, ...

At a quick glance, you can use the information <inotfy>.
However, the current implementation is the information is just printed.
The information is not recorded for the successive decoding processes.

masatake@19bbc9d
This change hooks printfd(), the core of -y option, for recording the information to struct tcb.

struct tcb has a field called priv to store such decoder-specific information.
However, if multiple decoders are involved in decoding one system call, the decoders may conflicts.
So I introduced priv field multiplexer.
masatake@d564e4c

Even if a user doesn't use -y option, you may want to decode the buffer.
So recording fd information and printing fd information should be able to be enabled independently.
For this purpose, I defined enable_tprint/disable_tprint.
masatake@bf6f39c
masatake@19bbc9d

You can find all my changes in "Aug 27, 2021" in https://github.com/masatake/strace/commits/vfio-draft

I hope my study helps you.
NOTE: my changes are not approved by @ldv-alt yet. As I wrote, I didn't submit the changes to the mailing list.

@esyr
Copy link
Member

esyr commented Oct 7, 2021

There was some PoC some time ago: 4f72de6 78fd3aa 8015a74

@esyr esyr added the patch label Nov 3, 2021
leedagee added a commit to leedagee/strace that referenced this issue Mar 25, 2023
When signalfds are used, normal signal handling method is not used
causing strace unable to catch these signals and therefore unable to
decode them.

This patch adds a basic a support for signalfd fdinfo decoding.
Decoding the buffer content needs more patch but there's also previous
work byh esyr and masatake (see github strace#199).

- decode-fds arguments and switches
- improved signalfd4 tests
leedagee added a commit to leedagee/strace that referenced this issue Mar 25, 2023
When signalfds are used, normal signal handling method is not used
causing strace unable to catch these signals and therefore unable to
decode them.

This patch adds a basic a support for signalfd fdinfo decoding.
Decoding the buffer content needs more patch but there's also previous
work byh esyr and masatake (see github strace#199).

- decode-fds arguments and switches
- improved signalfd4 tests
leedagee added a commit to leedagee/strace that referenced this issue Mar 25, 2023
When signalfds are used, normal signal handling method is not used
causing strace unable to catch these signals and therefore unable to
decode them.

This patch adds a basic a support for signalfd fdinfo decoding.
Decoding the buffer content needs more patch but there's also previous
work byh esyr and masatake (see github strace#199).

Signed-off-by: leedagee <leedageea@gmail.com>
leedagee added a commit to leedagee/strace that referenced this issue Mar 26, 2023
When signalfds are used, normal signal handling method is not used
causing strace unable to catch these signals and therefore unable to
decode them.

This patch adds a basic a support for signalfd fdinfo decoding.
Decoding the buffer content needs more patch but there's also previous
work byh esyr and masatake (see github strace#199).

Signed-off-by: leedagee <leedageea@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants