Hello,
This is a repost of the following (https://stackoverflow.com/questions/75630436/systemtap-ubuntu-22-04-2-compile-error-static-declaration-of-proc-set-user-fo ) SO question I opened a few days ago; I thought it'd be more fitting here:
I am running Ubuntu 22.04.02 over Linux kernel 5.19.0-32-generic. Systemtap version is 4.6-2.
I have installed systemtap following their Ubuntu tutorial. I took my kernel debug symbols following Ubuntu's wiki tutorial. Since I have SecureBoot enabled, I am "using" a compile server (hosted on my machine, same as the one on which I plan on executing the stap (localhost) ). Running -l "scripts" (e.g.: $ sudo stap -l 'syscall.*' --use-server=localhost) works fine, as only 3 of the 5 passes are needed.
The problem occurs when requesting a very simple probe:$ sudo stap -e 'probe begin {exit()}' --use-server=localhost . At pass 4 (compiling the generated C code), I get various compile errors:
====================================================================================================================================================
In file included from /usr/share/systemtap/runtime/transport/procfs.c:13,
from /usr/share/systemtap/runtime/transport/transport.c:72,
from /usr/share/systemtap/runtime/linux/print.c:17,
from /usr/share/systemtap/runtime/print.c:17,
from /usr/share/systemtap/runtime/runtime_context.h:22,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:49:
/usr/share/systemtap/runtime/proc_fs_compatibility.h:29:13: error: static declaration of ‘proc_set_user’ follows non-static declaration
29 | static void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
| ^~~~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/linux/runtime.h:22,
from /usr/share/systemtap/runtime/runtime.h:26,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:21:
./include/linux/proc_fs.h:112:13: note: previous declaration of ‘proc_set_user’ with type ‘void(struct proc_dir_entry *, kuid_t, kgid_t)’
112 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
| ^~~~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/transport/procfs.c:13,
from /usr/share/systemtap/runtime/transport/transport.c:72,
from /usr/share/systemtap/runtime/linux/print.c:17,
from /usr/share/systemtap/runtime/print.c:17,
from /usr/share/systemtap/runtime/runtime_context.h:22,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:49:
/usr/share/systemtap/runtime/proc_fs_compatibility.h: In function ‘proc_set_user’:
/usr/share/systemtap/runtime/proc_fs_compatibility.h:31:11: error: invalid use of undefined type ‘struct proc_dir_entry’
31 | de->uid = __kuid_val(uid);
| ^~
/usr/share/systemtap/runtime/proc_fs_compatibility.h:32:11: error: invalid use of undefined type ‘struct proc_dir_entry’
32 | de->gid = __kgid_val(gid);
| ^~
proc_remove
/usr/share/systemtap/runtime/proc_fs_compatibility.h:47:13: error: static declaration of ‘proc_remove’ follows non-static declaration
47 | static void proc_remove(struct proc_dir_entry *de)
| ^~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/linux/runtime.h:22,
from /usr/share/systemtap/runtime/runtime.h:26,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:21:
./include/linux/proc_fs.h:124:13: note: previous declaration of ‘proc_remove’ with type ‘void(struct proc_dir_entry *)’
124 | extern void proc_remove(struct proc_dir_entry *);
| ^~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/transport/procfs.c:13,
from /usr/share/systemtap/runtime/transport/transport.c:72,
from /usr/share/systemtap/runtime/linux/print.c:17,
from /usr/share/systemtap/runtime/print.c:17,
from /usr/share/systemtap/runtime/runtime_context.h:22,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:49:
/usr/share/systemtap/runtime/proc_fs_compatibility.h: In function ‘proc_remove’:
/usr/share/systemtap/runtime/proc_fs_compatibility.h:49:21: error: invalid use of undefined type ‘struct proc_dir_entry’
49 | if (de && de->subdir == NULL) {
| ^~
/usr/share/systemtap/runtime/proc_fs_compatibility.h:50:36: error: invalid use of undefined type ‘struct proc_dir_entry’
50 | if (atomic_read(&de->count) != LAST_ENTRY_COUNT)
| ^~
In file included from ./include/asm-generic/bug.h:22,
from ./arch/x86/include/asm/bug.h:87,
from ./include/linux/bug.h:5,
from ./include/linux/mmdebug.h:5,
from ./include/linux/gfp.h:5,
from /usr/share/systemtap/runtime/linux/runtime_defines.h:20,
from /usr/share/systemtap/runtime/runtime_defines.h:8,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:12:
/usr/share/systemtap/runtime/proc_fs_compatibility.h:54:34: error: invalid use of undefined type ‘struct proc_dir_entry’
54 | de->name);
| ^~
./include/linux/printk.h:436:33: note: in definition of macro ‘printk_index_wrap’
436 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
/usr/share/systemtap/runtime/proc_fs_compatibility.h:51:25: note: in expansion of macro ‘printk’
51 | printk(KERN_ERR "Removal of %s from /proc"
| ^~~~~~
In file included from /usr/share/systemtap/runtime/transport/procfs.c:13,
from /usr/share/systemtap/runtime/transport/transport.c:72,
from /usr/share/systemtap/runtime/linux/print.c:17,
from /usr/share/systemtap/runtime/print.c:17,
from /usr/share/systemtap/runtime/runtime_context.h:22,
from <server>/stap000000/stap_44621a3e20f38e1a82b1cb20ff27737b_949_src.c:49:
/usr/share/systemtap/runtime/proc_fs_compatibility.h:55:37: error: invalid use of undefined type ‘struct proc_dir_entry’
55 | remove_proc_entry(de->name, de->parent);
| ^~
/usr/share/systemtap/runtime/proc_fs_compatibility.h:55:47: error: invalid use of undefined type ‘struct proc_dir_entry’
55 | remove_proc_entry(de->name, de->parent);
| ^~
====================================================================================================================================================
The full error log, as well as more information, can be found in the output of running stap-report, hosted here: https://pastebin.com/vPRXMHzv
A warning that might be of importance in the file (though I doubt it) is :
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
You are using: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Given I have started my server with -B "-e CC=/usr/bin/x86_64-linux-gnu-gcc", I don't exactly know how to fix the warning without changing my whole system's CC environment variable.
Would anyone know what causes the problem, or how to solve it?
Thanks in advance!
These kinds of things can happen when the kernel version leaps way ahead of the time when systemtap was released. (The kernel has no stable API, so systemtap's runtime must constantly play catch-up.). For your 5.19.0-32-generic kernel, you'd need a systemtap version 4.8.
https:/ /sourceware. org/pipermail/ systemtap/ 2022q4/ 027563. html
See also, e.g.:
% stap -V | grep version
Systemtap translator/driver (version 4.8/0.188, rpm 4.8-3.fc37)
tested kernel versions: 2.6.32 ... 6.1.0-rc3