compile error: static declaration of ‘proc_set_user’ follows non-static declaration and others

Bug #2009302 reported by VG
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemtap (Ubuntu)
New
Undecided
Unassigned

Bug Description

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!

VG (csp5336)
description: updated
Revision history for this message
Frank Ch. Eigler (fche) wrote :

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

Revision history for this message
VG (csp5336) wrote :

Thank you for your answer ! The ubuntu package seems to be out of date (https://packages.ubuntu.com/jammy/systemtap). Resolved to building release-4.8 from source by following the instructions (https://sourceware.org/git/?p=systemtap.git;a=blob_plain;f=README;hb=HEAD ).

Unfortunately however, after building and installing the newer version ( stap -V | grep version now correctly outputs "Systemtap translator/driver (version 4.8/0.186, release-4.8" ), I can't seem to connect to my localhost server (which I use because I have SecureBoot on):

* Server started with $ sudo stap-server start -a "x86_64" -u "username" -B "-e CC=/usr/bin/x86_64-linux-gnu-gcc" --ssl /home/username/.systemtap/ssl/server

* Running stap: $ sudo stap -vvv -l 'syscall.*'
This host requires module signing.
The kernel on your system requires modules to be signed for loading.
The module created by compiling your script must be signed by a systemtap compile-server. [man stap-server]
--use-server was automatically selected in order to request compilation by a compile-server.
Unable to request compilation by a compile-server
.Without NSS, --use-server is not supported by this version systemtap.

* Trying to list the servers yields: $ sudo stap -vvv -l 'syscall.*' --list-servers=all
WARNING: --list-servers is not supported by this version of systemtap

followed by the same error as when running stap.

* /home/username/.systemtap/ssl/server (which is also the default directory stap should be searching for ssl certs in my case, as described in man stappaths) correctly contains certificates: $ ls /home/username/.systemtap/ssl/server/
cert9.db key4.db moks pkcs11.txt stap.cert

(though the `moks` directory is empty, I'm unsure if this should be so)

Would you know where the error could come from? The server log doesn't contain anything besides the usual "stap-server" start message.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.