public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "wcohen at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/29028] New: Linux 5.18.0 kernels changed struct kretprobe_instance member fields and scripts with return probes fail to compile
Date: Tue, 05 Apr 2022 19:07:55 +0000	[thread overview]
Message-ID: <bug-29028-6586@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-04-05 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 19:07 wcohen at redhat dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29028-6586@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).