Backport PR33428: imply kernel<vmlinux.h> check by file name

Resolves: RHEL-105777
This commit is contained in:
Martin Cermak 2025-11-13 16:59:24 +01:00
parent 6042ae2f65
commit 89af0d93f3
2 changed files with 74 additions and 2 deletions

View File

@ -0,0 +1,66 @@
From 53c48b550255ceca1216616fe1948618be166189 Mon Sep 17 00:00:00 2001
From: "Frank Ch. Eigler" <fche@redhat.com>
Date: Wed, 12 Nov 2025 18:51:26 -0500
Subject: [PATCH] PR33428: imply kernel<vmlinux.h>, check by file name, cont'd
Linux 5.7+ includes a vmlinux.h file ... but previous code looked for
version 6.7+ by mistake. Might as well just look for the vmlinux.h
file directly in the build tree, and leave a little diagnostic note.
---
tapsets.cxx | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/tapsets.cxx b/tapsets.cxx
index d267b6506..ae201ab26 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4867,8 +4867,12 @@ dwarf_var_expanding_visitor::visit_cast_op (cast_op *e)
if (is_user_module (q.dw.module_name))
e->module = q.dw.module_name;
else if ((strverscmp(sess.compatible.c_str(), "5.4") >= 0) && // default on new enough systemtap
- (strverscmp(sess.kernel_base_release.c_str(), "6.7") >= 0)) // for new enough kernel to have a vmlinux.h
- e->module = string(TOK_KERNEL_VMLINUX_H) + string(":") + q.dw.module_name; // PR33428: prefix
+ access(string(sess.kernel_build_tree+"/vmlinux.h").c_str(), R_OK) == 0) // file exists; not just kernel 6.7+
+ {
+ if (sess.verbose > 3)
+ clog << _("added implicit kernel<vmlinux.h> for @cast context") << " " << q.dw.module_name << endl;
+ e->module = string(TOK_KERNEL_VMLINUX_H) + string(":") + q.dw.module_name; // PR33428: prefix
+ }
else
e->module = q.dw.module_name;
}
@@ -5166,16 +5170,21 @@ void dwarf_cast_expanding_visitor::visit_cast_op (cast_op* e)
// PR33428: prepend "kernel<vmlinux.h>" to the list if there is any
// "kernel" or "kernel<FILE>" component.
if ((strverscmp(sess.compatible.c_str(), "5.4") >= 0) && // default on new enough systemtap
- (strverscmp(sess.kernel_base_release.c_str(), "6.7") >= 0) && // for new enough kernel to have a vmlinux.h
- (e->module.find(TOK_KERNEL_VMLINUX_H) == string::npos)) // don't prepend again; might already be here from implicit "" expansion
- {
- if (e->module.starts_with("kernel")) // right at the front?
- e->module = string(TOK_KERNEL_VMLINUX_H) + string(":") + e->module;
- else {
- string::size_type p = e->module.find(":kernel"); // in the middle?
- if (p != string::npos)
- e->module.insert(p, TOK_KERNEL_VMLINUX_H + string (":"));
- }
+ access(string(sess.kernel_build_tree+"/vmlinux.h").c_str(), R_OK) == 0) // file exists; not just kernel 6.7+
+ {
+ if (sess.verbose > 3)
+ clog << _("added implicit kernel<vmlinux.h> for @cast expanding") << " " << e->module << endl;
+
+ if (e->module.find(TOK_KERNEL_VMLINUX_H) == string::npos) // don't prepend again; might already be here from implicit "" expansion
+ {
+ if (e->module.starts_with("kernel")) // right at the front?
+ e->module = string(TOK_KERNEL_VMLINUX_H) + string(":") + e->module;
+ else {
+ string::size_type p = e->module.find(":kernel"); // in the middle?
+ if (p != string::npos)
+ e->module.insert(p, TOK_KERNEL_VMLINUX_H + string (":"));
+ }
+ }
}
tokenize(e->module, modules, ":");
--
2.51.0

View File

@ -131,7 +131,7 @@ f /var/log/stap-server/log 0644 stap-server stap-server -
Name: systemtap
# PRERELEASE
Version: 5.4
Release: 1%{?release_override}%{?dist}
Release: 2%{?release_override}%{?dist}
# for version, see also configure.ac
@ -169,6 +169,8 @@ License: GPL-2.0-or-later
URL: https://sourceware.org/systemtap/
Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
Patch1: 0001-PR33428-imply-kernel-vmlinux-h.patch
# Build*
BuildRequires: make
BuildRequires: gcc-c++
@ -612,7 +614,7 @@ or within a container.
# ------------------------------------------------------------------------
%prep
%setup -q
%autosetup -p1
%build
@ -1363,6 +1365,10 @@ exit 0
# PRERELEASE
%changelog
* Thu Nov 13 2025 Martin Cermak <mcermak@redhat.com> - 5.4-2
- Backport upstream patch 53c48b550 imply kernel<vmlinux.h>
check by file name.
* Fri Oct 31 2025 Frank Ch. Eigler <fche@redhat.com> - 5.4-1
- Upstream release, see wiki page below for detailed notes.
https://sourceware.org/systemtap/wiki/SystemTapReleases