6.7.0-3-rt-MANJARO headers not matching the kernel version prevents loading custom modules

Hello, I’m unsure where to post this, but posting it here as it’s MANJARO kernels related. If this doesn’t belong here, I’m happy to move it. Would appreciate any pointers for where to post this

Issue

Put it short, I want to give a go at creating a hello kernel module & loading it up.

I have 6.7.7-1-MANJARO kernel, whose latest headers have a different name and version to them 6.7.0-3-rt6-MANJARO.

When I build the hello module & try loading it, I get Invalid module format error, which seems to be cause by version mismatch. More details below:

More Info

Finding headers folder

The /usr/lib/modules/6.7.7-1-MANJARO module has neither the include, nor build under it.

Looking up the package manager:

$ pacman -Qs linux67
local/linux67 6.7.7-1
    The Linux67 kernel and modules
local/linux67-rt-headers 6.7_rt6-3
    Header files and scripts for building modules for Linux67-rt kernel

Shows the headers for my current kernel version are installed. Looking up the directories of kernel headers gives:

$ pacman -Ql linux67-rt-headers
... etc.
linux67-rt-headers /usr/lib/modules/6.7.0-3-rt6-MANJARO/build/vmlinux
linux67-rt-headers /usr/src/linux67-rt

Check for newer headers version

So my kernel headers version is 6.7.0-3-rt6-MANJARO.

I’ve synced up & upgradde pacman with pacman -Syu (all is up-to-date) and looked up the latest header version:

$ pacman -Ss kernel | grep -iA1 headers
...etc.
core/linux67-rt-headers 6.7_rt6-3 [installed]
    Header files and scripts for building modules for Linux67-rt kernel
---
...etc.

Appears, I have the latest version.

Finding where to point Makefile

So looking up usr lib modules gives:

$ ls /usr/lib/modules/
6.7.0-3-rt6-MANJARO  6.7.7-1-MANJARO

Under the 6.7.0-3-rt6-MANJARO directory there’s only 1 directory called build. So clearly that’s where I need to point my hello module Makefile to:
KERNELDIR ?= /usr/lib/modules/6.7.0-3-rt6-MANJARO/build

Loading module

When I build the my hello module and get my hello.ko, loading it gives error:

$ sudo insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Invalid module format

Looking up more detail gives the following error:

$  sudo dmesg | tail
[ 2788.287361] hello: version magic '6.7.0-3-rt6-MANJARO SMP preempt mod_unload ' should be '6.7.7-1-MANJARO SMP preempt mod_unload '

Question:

What is exactly the problem here? These seem to be the correct headers & checking pacman shows there’s newer better to install to match the kernel version.

Extra Info:

project Makefile:

LDDINC=$(PWD)/../include
EXTRA_CFLAGS += -I$(LDDINC)

ifeq ($(KERNELRELEASE),)

    # Assume the source tree is where the running kernel was built
    # You should set KERNELDIR in the environment if it's elsewhere
    KERNELDIR ?= /usr/lib/modules/6.7.0-3-rt6-MANJARO/build
    # The current directory is passed to sub-makes as argument
    PWD := $(shell pwd)

modules:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
	rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions *.mod modules.order *.symvers

.PHONY: modules modules_install clean

else
    # called from kernel build system: just declare what our modules are
    obj-m := hello.o
endif

hello.c module

#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("DUAL BSD/GPL");

static int hello_init(void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, cruel world!\n");
}

module_init(hello_init);
module_exit(hello_exit);

vs_code json for imports

{
    "configurations": [
        {
            "name": "driver",
            "defines": [
                "__KERNEL__",
                "MODULE"
            ],
            "compilerPath": "/usr/bin/gcc",
            // "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "gcc-x64",
            // "intelliSenseMode": "linux-clang-x64",
            "configurationProvider": "ms-vscode.makefile-tools",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/lib/modules/6.7.0-3-rt6-MANJARO/**",
                "/usr/lib/modules/6.7.7-1-MANJARO/**",
                "/usr/src/linux67-rt/**",
                "/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include"
            ],
            "compilerArgs": [
                "-nostdinc",
                "-include", "/usr/src/linux67-rt/include/linux/kconfig.h",
                "-include", "/usr/src/linux67-rt/include/linux/compiler_types.h"
            ]
        }
    ],
    "version": 4
}

There’s probably a bunch of stuff here that doesn’t need to be, but I have no idea what’s needed yet, so I included it all until the squiggly line was gone.

Kernel 6.7 has been EOL & unsupported for more than 2 months, so you should switch to a supported kernel such as 6.6 (LTS) or 6.9 (Manjaro’s latest).

Is there any specific reason why you have installed a real-time kernel ( 6.7.0-3-rt6-MANJARO)? Usually RT kernels are for specific uses such as audio processing - they should not be used as a day-to-day kernel.

1 Like

Your are running a removed, unsupported and insecure Kernel. Install a supported one!

Do not mix RT Kernel Headers and normal Kernels. As you noticed, they are not the same. If you need a RT Kernel, you might want top install linux67-rt and boot this Kernel. Keep in mind RT makes everything slower but predictable.

1 Like

“Is there any specific reason why you have installed a real-time kernel”

At the time when I installed I just didn’t know any better. I only learned what the RT is for yesterday when I encountered this version mismatch & started looking into what this RT is. But thanks for bringing it up regardless!

Totally my bad - I must have missed the announcement of it rotating out of support! And apparently I didn’t make the distinction between linux67 and linux67-rt. Thanks for pointing that out.

I’m still somewhat puzzled as to how the RT headers were meant to work with my kernel version before it got out of support. But I suppose it doesn’t matter much - I will give it a go with the newer kernel version as suggested.

Thank you all very much for your quick responses!

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.