-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
tools.py: Allow args dereference #1936
base: master
Are you sure you want to change the base?
Conversation
libc functions like for example eventfd_read() int eventfd_read(int fd, eventfd_t *value); may be passed with pointer argument. Applying star ('*') to such argument must safely copy a memory location to the BPF stack. Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
This is the smallest (all error handling removed) eventfd_read program I tested with.
Here is the output of trace.py
reported 7 failures with and without my patches Uploading smoke test results. |
return text + """ | ||
if (%s != 0) { | ||
bpf_probe_read(&__data.v%d, sizeof(__data.v%d), (void *)%s); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need the if
condition in the above. User has a dereference and we should just honor it. bpf_probe_read won't crash the kernel. This will be consistent with other rewriter changes related to
bpf_probe_read as we do not really check return value for bpf_probe_read.
Typically, rewriter should handle *
expressions properly. The exception is for anonymous function parameters like arg1, arg2, etc, which are replaced with PT_REGS_PARM1, etc. where *PT_REGS_PARM1(ctx)
won't work due to type mismatch. One way could be to only handle arg1/arg2/arg3/arg4/arg5/arg/retval
here and leave others to be handled by rewriter. But I am okay to handle all cases of *<...>
here for simplicity as done in the above.
Could you put an example in trace.py and trace_example.txt? For example, the command line for your example in this pull request?
BTW your title should be " |
libc functions like for example eventfd_read()
may be passed with pointer argument.
Applying star ('*') to such argument must safely copy a memory location
to the BPF stack.
Signed-off-by: Prasad Joshi prasadjoshi.linux@gmail.com