GrubbyHalo
Posts: 29
Joined: Thu Jul 10, 2014 9:33 am

Problem matching module with installed kernel version

Fri Feb 21, 2020 9:33 am

Hi all

I have a bunch of pi's out there that i want to install wireguard on. Those pi's have a custom kernel on them (4.4.11-v7+) So i pulled that commit of the raspbian kernel ( https://github.com/raspberrypi/linux/tr ... 613c8c0b83 ) and compiled the module against that.

The first issue i came across was that the version of the module did not match the kernel version. doing modinfo on the module gave me a vermagic number of 4.4.11-v7 instead of 4.4.11-v7+. No problem! i just did:

Code: Select all

make menuconfig 
and went to General Setup -> Local version - append to kernel release and added -v7+ and recompiled the kernel
Alas, i still couldn't get the module loaded.

Code: Select all

$ sudo modprobe wireguard
modprobe: ERROR: could not insert 'wireguard': Exec format error
$ dmesg
wireguard: disagrees about version of symbol module_layout

but if i check the module info using:

Code: Select all

$ modinfo wireguard
filename:       /lib/modules/4.4.11-v7+/extra/wireguard.ko
alias:          net-pf-16-proto-16-family-wireguard
alias:          rtnl-link-wireguard
version:        0.0.20200215-2-g118398c-dirty
author:         Jason A. Donenfeld <[email protected]>
description:    WireGuard secure network tunnel
license:        GPL v2
srcversion:     1FE16E62C7697F976B7CF38
depends:        ipv6,udp_tunnel,ip6_udp_tunnel
vermagic:       4.4.11-v7+ SMP mod_unload modversions ARMv7 p2v8 
and uname -a gives me:

Code: Select all

$ uname -a
Linux raspberrypi 4.4.11-v7+ #1 SMP Mon Jun 27 11:02:12 SAST 2016 armv7l GNU/Linux
What could be wrong ?

Thanks in advance to the brainiac that helps me sort this one out

Kendek
Posts: 145
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: Problem matching module with installed kernel version

Sat Feb 22, 2020 12:39 pm

You need to use the original - custom - kernel source with the same - custom - .config file. Apply the Wireguard patch, prepare the kernel and compile the module.
This is how I compile the Wireguard module for the Synology routers:

Code: Select all

wireguard-linux-compat-*/kernel-tree-scripts/jury-rig.sh linux-4.4.x
cd linux-4.4.x
printf "CONFIG_WIREGUARD=m\n# CONFIG_WIREGUARD_DEBUG is not set\n" >>.config
make oldconfig
make prepare scripts
make M=net/wireguard modules
strip --strip-debug net/wireguard/wireguard.ko

GrubbyHalo
Posts: 29
Joined: Thu Jul 10, 2014 9:33 am

Re: Problem matching module with installed kernel version

Sun Feb 23, 2020 8:18 am

You need to use the original - custom - kernel source with the same - custom - .config file. Apply the Wireguard patch, prepare the kernel and compile the module.
This is how I compile the Wireguard module for the Synology routers:
I don't have the original kernel source. Thats why i pulled the same version from the raspbian kernel repo. I also got the config from a running device that is running that kernel version i.e.:

Code: Select all

sudo modprobe configs

Kendek
Posts: 145
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: Problem matching module with installed kernel version

Sun Feb 23, 2020 8:58 am

GrubbyHalo wrote:
Sun Feb 23, 2020 8:18 am
I don't have the original kernel source. Thats why i pulled the same version from the raspbian kernel repo.
If your custom kernel was compiled from 544ec5b without any source code modifications, then this is the original kernel source. You just need to configure and prepare it before compiling the WG module.

GrubbyHalo
Posts: 29
Joined: Thu Jul 10, 2014 9:33 am

Re: Problem matching module with installed kernel version

Mon Feb 24, 2020 7:34 am

If your custom kernel was compiled from 544ec5b without any source code modifications, then this is the original kernel source. You just need to configure and prepare it before compiling the WG module.
There was no source code modification at all. And if you look at my original post you will see that the vermagic of the compiled wireguard module is pretty much the same as running uname -r on the running version.

So i don't understand why i am getting the

Code: Select all

 wireguard: disagrees about version of symbol module_layout 
message.

could it be because ARMv7

Code: Select all

p2v8
is enabled in the kernel i am building the module against ? Would running

Code: Select all

 uname -a 
actually indicate this to me on a running kernel ? Would disabling

Code: Select all

 CONFIG_ARM_PATCH_PHYS_VIRT 
solve the problem ?

Kendek
Posts: 145
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: Problem matching module with installed kernel version

Mon Feb 24, 2020 3:45 pm

GrubbyHalo wrote:
Mon Feb 24, 2020 7:34 am
There was no source code modification at all. And if you look at my original post you will see that the vermagic of the compiled wireguard module is pretty much the same as running uname -r on the running version.

So i don't understand why i am getting the

Code: Select all

 wireguard: disagrees about version of symbol module_layout
message.
The vermagic and the symbol module_layout are not the same things.

GrubbyHalo
Posts: 29
Joined: Thu Jul 10, 2014 9:33 am

Re: Problem matching module with installed kernel version

Tue Feb 25, 2020 7:21 am

Code: Select all

The vermagic and the symbol module_layout are not the same things.
I realize that. The reason i mention it is to show that i compiled the module against the same version of kernel running on the device.
According to this there might still be configuation options that are still different. But i find that strange because i got the config from the running kernel by:

Code: Select all

sudo modprobe configs

Return to “Advanced users”