public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/29028] New: Linux 5.18.0 kernels changed struct kretprobe_instance member fields and scripts with return probes fail to compile
@ 2022-04-05 19:07 wcohen at redhat dot com
  2022-04-25 20:50 ` [Bug translator/29028] " wcohen at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wcohen at redhat dot com @ 2022-04-05 19:07 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=29028

            Bug ID: 29028
           Summary: Linux 5.18.0 kernels changed struct kretprobe_instance
                    member fields and scripts with return probes fail to
                    compile
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: wcohen at redhat dot com
  Target Milestone: ---

The following kernel commit 73f9b911faa74ac5107879de05c9489c419f41bb in the
linux 5.18.0-rc kernel changed the struct kretprobe_instance members which
causes scripts with return kernel probes fail to build:

    kprobes: Use rethook for kretprobe if possible

    Use rethook for kretprobe function return hooking if the arch sets
    CONFIG_HAVE_RETHOOK=y. In this case, CONFIG_KRETPROBE_ON_RETHOOK is
    set to 'y' automatically, and the kretprobe internal data fields
    switches to use rethook. If not, it continues to use kretprobe
    specific function return hooks.

    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link:
https://lore.kernel.org/bpf/164826162556.2455864.12255833167233452047.stgit@devnote2

On Fedora 37 (rawhide) running
kernel-5.18.0-0.rc0.20220401gite8b767f5e04097a.15.fc37.x86_64 and locally built
systemtap from git checkout can replicate the issue with:

$ sudo ../install/bin/stap --example alias_suffixes.stp -T 1
In file included from
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/../regs.c:16,
                 from
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/runtime.h:270,
                 from
/home/wcohen/systemtap_write/install/share/systemtap/runtime/runtime.h:26,
                 from
/tmp/stapIaZ5Mo/stap_90ca7a4095946c1447d5febbb2252e46_85937_src.c:21:
/tmp/stapIaZ5Mo/stap_90ca7a4095946c1447d5febbb2252e46_85937_src.c: In function
‘enter_kretprobe_common’:
/tmp/stapIaZ5Mo/stap_90ca7a4095946c1447d5febbb2252e46_85937_src.c:6484:45:
error: ‘struct kretprobe_instance’ has no member named ‘ret_addr’
 6484 |         SET_REG_IP(regs, (unsigned long)inst->ret_addr);
      |                                             ^~
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/../regs.h:85:44:
note: in definition of macro ‘SET_REG_IP’
   85 | #define SET_REG_IP(regs, x) REG_IP(regs) = x
      |                                            ^
make[1]: *** [scripts/Makefile.build:288:
/tmp/stapIaZ5Mo/stap_90ca7a4095946c1447d5febbb2252e46_85937_src.o] Error 1
make: *** [Makefile:1848: /tmp/stapIaZ5Mo] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed.  [man error::pass4]


There are a number of places in tapsets.cxx directly referencing ret_addr field
which is removed from struct kretprobe_instance.  Looking at how the kernel
handles this there is small inlined helper function to "do the right thing",
get_kretprobe_retaddr
(https://elixir.bootlin.com/linux/v5.18-rc1/C/ident/get_kretprobe_retaddr). 
Looks like systemtap should have a similar __stp_* function to do the same.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-26 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 19:07 [Bug translator/29028] New: Linux 5.18.0 kernels changed struct kretprobe_instance member fields and scripts with return probes fail to compile wcohen at redhat dot com
2022-04-25 20:50 ` [Bug translator/29028] " wcohen at redhat dot com
2022-04-26  2:59 ` wcohen at redhat dot com
2022-04-26 18:27 ` wcohen at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).