Skip to content

make all failing on Kernel v5.9 because proc_create kernel api is changed #143

Open
@KZYSAKYM

Description

@KZYSAKYM

I tried to build dtrace on kernel v5.9 distributed by ParrotOS.

$ git clone "https://github.com/dtrace4linux/linux.git" dtrace
$ cd dtrace
$ tools/get-deps.pl
$ make all 
BUILD_DIR=build-5.9.0-2parrot1-amd64 \
tools/mkdriver.pl driver-kmem ; \
tools/build.pl build-5.9.0-2parrot1-amd64 `uname -m`
symlink ../../driver-kmem/Makefile build-5.9.0-2parrot1-amd64/driver-kmem/Makefile
symlink ../../driver-kmem/dtrace_kmem.c build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c
Executing: /home/builder/dtrace/tools/make-me
make -C /lib/modules/5.9.0-2parrot1-amd64/build M=/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem
  AR      /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/built-in.a
  CC [M]  /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o
/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c: In function 'kmem_init':
/home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c:61:51: error: passing argument 4 of 'proc_create' from incompatible pointer type [-Werror=incompatible-pointer-types]
   61 |  proc_create("dtrace_kmem", S_IFREG | 0400, NULL, &proc_kmem);
      |                                                   ^~~~~~~~~~
      |                                                   |
      |                                                   struct file_operations *
In file included from /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.c:16:
/usr/src/linux-headers-5.9.0-2parrot1-common/include/linux/proc_fs.h:107:122: note: expected 'const struct proc_ops *' but argument is of type 'struct file_operations *'
  107 |  mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

cc1: some warnings being treated as errors
make[3]: *** [/usr/src/linux-headers-5.9.0-2parrot1-common/scripts/Makefile.build:288: /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem/dtrace_kmem.o] Error 1
make[2]: *** [/usr/src/linux-headers-5.9.0-2parrot1-common/Makefile:1796: /home/builder/dtrace/build-5.9.0-2parrot1-amd64/driver-kmem] Error 2
make[1]: *** [/usr/src/linux-headers-5.9.0-2parrot1-common/Makefile:185: __sub-make] Error 2
gcc -o build-5.9.0-2parrot1-amd64/kcore tools/kcore.c
tools/check_dep.pl
tools/mkport.pl
/tmp/builder.dwarf.c: In function ‘main’:
/tmp/builder.dwarf.c:5:2: warning: implicit declaration of function ‘dwarf_loclist’ [-Wimplicit-function-declaration]
    5 |  dwarf_loclist();
      |  ^~~~~~~~~~~~~
/usr/bin/ld: cannot find -ldw
collect2: error: ld returned 1 exit status
Failed to find stub_execve
Use of uninitialized value $old_rsp in concatenation (.) or string at tools/mkport.pl line 144.
old_rsp=
We cannot find old_rsp or per_cpu__old_rsp in your kernel.
Additionally, it looks like /proc/kcore is broken on your kernel,
meaning we cannot poke to find this variable, which helps identify
kernel thread offsets.
FATAL ERROR: cannot find old_rsp
FATAL ERROR: build.pl aborting
make: *** [makefile:67: all] Error 25

proc_create is different between v4 and v5.

This changing was done in the following commit.

commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9
Author: Alexey Dobriyan <[email protected]>
Date:   Mon Feb 3 17:37:14 2020 -0800

    proc: decouple proc from VFS with "struct proc_ops"
    
    Currently core /proc code uses "struct file_operations" for custom hooks,
    however, VFS doesn't directly call them.  Every time VFS expands
    file_operations hook set, /proc code bloats for no reason.
    
    Introduce "struct proc_ops" which contains only those hooks which /proc
    allows to call into (open, release, read, write, ioctl, mmap, poll).  It
    doesn't contain module pointer as well.
    
    Save ~184 bytes per usage:
    
            add/remove: 26/26 grow/shrink: 1/4 up/down: 1922/-6674 (-4752)
            Function                                     old     new   delta
            sysvipc_proc_ops                               -      72     +72
                                    ...
            config_gz_proc_ops                             -      72     +72
            proc_get_inode                               289     339     +50
            proc_reg_get_unmapped_area                   110     107      -3
            close_pdeo                                   227     224      -3
            proc_reg_open                                289     284      -5
            proc_create_data                              60      53      -7
            rt_cpu_seq_fops                              256       -    -256
                                    ...
            default_affinity_proc_fops                   256       -    -256
            Total: Before=5430095, After=5425343, chg -0.09%
    
    Link: http://lkml.kernel.org/r/20191225172228.GA13378@avx2
    Signed-off-by: Alexey Dobriyan <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>

This appears in v5.6-rc1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions