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

subprogram support causes problems accessing fentry args named 'fn' #3177

Open
tyroguru opened this issue May 16, 2024 · 3 comments
Open

subprogram support causes problems accessing fentry args named 'fn' #3177

tyroguru opened this issue May 16, 2024 · 3 comments
Labels
bug Something isn't working difficulty: easy good first issue Good for newcomers priority: low

Comments

@tyroguru
Copy link
Contributor

What reproduces the bug? Provide code if possible.

On a 5.19 kernel with bpftrace HEAD commit == 742f0cf we get a naming clash when attempting to access an fentry argument named 'fn'.

$ sudo ./bpftrace -lv fentry:vmlinux:module_kallsyms_on_each_symbol
kfunc:vmlinux:module_kallsyms_on_each_symbol
    const char * modname
    int (*)(void *, const char *, struct module *, unsigned long) fn
    void * data
    int retval

$ sudo ./bpftrace -e 'fentry:vmlinux:module_kallsyms_on_each_symbol{ $t = args.fn; }'
stdin:1:53-60: ERROR: syntax error, unexpected subprog
fentry:vmlinux:module_kallsyms_on_each_symbol{ $t = args.fn; }
                                                    ~~~~~~~

@ajor suggested adding the SUBPROG token as a known keyword in the grammar as so:

diff --git a/src/parser.yy b/src/parser.yy
index 85c8a20e..89efca28 100644
--- a/src/parser.yy
+++ b/src/parser.yy
@@ -628,6 +628,7 @@ keyword:
         |       SIZEOF        { $$ = $1; }
         |       UNROLL        { $$ = $1; }
         |       WHILE         { $$ = $1; }
+        |       SUBPROG       { $$ = $1; }
         ;

The above modification makes bpftrace happier but whether it is a complete fix is another thing.

$ sudo ./bpftrace -e 'fentry:vmlinux:module_kallsyms_on_each_symbol{ $t = args.fn; }'
Attaching 1 probe...
ERROR: Error loading program: kfunc:vmlinux:module_kallsyms_on_each_symbol (try -v)

(The error here is a verifier problem and should be ignored for the purpose of this bug).

bpftrace --info output

@tyroguru tyroguru added the bug Something isn't working label May 16, 2024
@viktormalik
Copy link
Contributor

cc @lenticularis39

@lenticularis39
Copy link
Contributor

Oops, I planned to "do that later" for fn also (the addition to the grammar) and forgot, thanks for reporting that!

@lenticularis39
Copy link
Contributor

fn will never appear in the place of an identifier, since subprog definitions are top-level so there is no problem with parsing it as a keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working difficulty: easy good first issue Good for newcomers priority: low
Projects
None yet
Development

No branches or pull requests

4 participants