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

"args.retval" broken in kfuncs #3059

Open
ajor opened this issue Mar 14, 2024 · 2 comments
Open

"args.retval" broken in kfuncs #3059

ajor opened this issue Mar 14, 2024 · 2 comments
Labels

Comments

@ajor
Copy link
Member

ajor commented Mar 14, 2024

Probe listing claims that k[ret]funcs have "retval" arguments:

# bpftrace -lv kfunc:finish_task_switch
kfunc:vmlinux:finish_task_switch
    struct task_struct * prev
    struct rq * retval
# bpftrace -lv kretfunc:finish_task_switch
kretfunc:vmlinux:finish_task_switch
    struct task_struct * prev
    struct rq * retval

But it's not possible to access them:

$ sudo bpftrace -e 'kfunc:finish_task_switch { print(args.retval) }'
stdin:1:28-39: ERROR: Can't find function parameter retval
kfunc:finish_task_switch { print(args.retval) }
                           ~~~~~~~~~~~
# bpftrace -e 'kretfunc:finish_task_switch { print(args.retval) }'
stdin:1:31-42: ERROR: Can't find function parameter retval
kretfunc:finish_task_switch { print(args.retval) }
                              ~~~~~~~~~~~

Printing the entire args struct shows no "retval" for kfuncs:

# bpftrace -e 'kfunc:finish_task_switch { print(args) }'
{ .prev = 0xffff88a086cc3280 }

But does for kretfuncs:

# bpftrace -e 'kretfunc:finish_task_switch { print(args) }'
{ .prev = 0xffff888107ac9940, .$retval = 0x0 }
@ajor ajor added the bug Something isn't working label Mar 14, 2024
@ajor ajor changed the title "retval" arguments broken in kfuncs "args.retval" broken in kfuncs Mar 14, 2024
@viktormalik
Copy link
Contributor

IIRC, we use the retval builtin for these cases. But since retval is listed as a field in listing, I guess that we could support args.retval, too. Shouldn't be too hard to implement, we just need to handle the situation when the function has an argument called retval (should happen very rarely).

@ajor
Copy link
Member Author

ajor commented Mar 14, 2024

I think it'd also be fine to require use of the retval builtin and not allow args.retval to be used - it's just the inconsistencies between listing/field accesses/printing that need to be fixed.

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

No branches or pull requests

2 participants