Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for loadable kernel modules #10450

Open
1 of 2 tasks
pdgendt opened this issue Sep 6, 2023 · 5 comments
Open
1 of 2 tasks

Feature request: Support for loadable kernel modules #10450

pdgendt opened this issue Sep 6, 2023 · 5 comments
Labels

Comments

@pdgendt
Copy link

pdgendt commented Sep 6, 2023

Windows Version

Microsoft Windows [Version 10.0.22621.2215]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.90.1

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

# clone the WSL2 kernel
$ git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
$ cd WSL2-Linux-Kernel
$ git checkout linux-msft-wsl-5.15.90.1

# Set kernel version
$ uname -r
5.15.90.1-microsoft-standard-WSL2

$ export KERNELRELEASE=$(uname -r)

# copy the WSL2 config
$ cp Microsoft/config-wsl .config

# enable driver module (CONFIG_USB_NET_AX88179_178A=m in my case)
$ make menuconfig

# build
$ make KERNELRELEASE=$KERNELRELEASE
$ make KERNELRELEASE=$KERNELRELEASE modules

# install
$ sudo make KERNELRELEASE=$KERNELRELEASE modules_install

# load module
$ modinfo ax88179_178a
filename:       /lib/modules/5.15.90.1-microsoft-standard-WSL2/kernel/drivers/net/usb/ax88179_178a.ko
license:        GPL
description:    ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices
srcversion:     6C1FCF063025567E7E0CF65
alias:          usb:v0711p0179d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0930p0A13d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v050Dp0128d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v17EFp304Bd*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v04E8pA100d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0DF6p0072d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v2001p4A00d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v04B4p3610d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0B95p178Ad*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0B95p1790d*dc*dsc*dp*ic*isc*ip*in*
depends:
retpoline:      Y
intree:         Y
name:           ax88179_178a
vermagic:       5.15.90.1-microsoft-standard-WSL2 SMP mod_unload modversions

$ sudo modprobe ax88179_178a
modprobe: ERROR: could not insert 'ax88179_178a': Invalid argument

$ dmesg # relevant part
[ 1827.985623] BPF:      type_id=1113 bits_offset=0
[ 1827.986241] BPF:
[ 1827.986489] BPF:Invalid name
[ 1827.986693] BPF:

[ 1827.986852] failed to validate module [ax88179_178a] BTF: -22

Expected Behavior

I expect the module to be loaded and useable after modprobe.

Actual Behavior

An error occurs:

$ sudo modprobe ax88179_178a
modprobe: ERROR: could not insert 'ax88179_178a': Invalid argument

$ dmesg # relevant part
[ 1827.985623] BPF:      type_id=1113 bits_offset=0
[ 1827.986241] BPF:
[ 1827.986489] BPF:Invalid name
[ 1827.986693] BPF:

[ 1827.986852] failed to validate module [ax88179_178a] BTF: -22

Diagnostic Logs

No response

@pdgendt
Copy link
Author

pdgendt commented Sep 6, 2023

Same for other USB 3.0 to ethernet adapter, dmesg:

[12429.363197] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3)
[12429.363200] vhci_hcd vhci_hcd.0: devid(458754) speed(5) speed_str(super-speed)
[12429.363220] vhci_hcd vhci_hcd.0: Device attached
[12429.711635] usb 2-1: SetAddress Request (4) to port 0
[12429.711643] usb 2-1: new SuperSpeed USB device number 4 using vhci_hcd
[12429.745247] usb 2-1: New USB device found, idVendor=17ef, idProduct=7205, bcdDevice=30.00
[12429.745250] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
[12429.745251] usb 2-1: Product: Thinkpad USB LAN
[12429.745252] usb 2-1: Manufacturer: Lenovo
[12429.745252] usb 2-1: SerialNumber: 10E40D000000
[12429.753826] BPF:[135141] ENUM nce
[12429.754370] BPF:size=4 vlen=11
[12429.754475] BPF:
[12429.754542] BPF:Invalid name
[12429.754641] BPF:

[12429.754740] failed to validate module [r8152] BTF: -22

@elsaco
Copy link

elsaco commented Sep 7, 2023

@pdgendt to use the new module make sure the booted kernel and the module(s) are from the same build. You already build a new kernel. Add it to .wslconfig and your module will load okay:

dmesg output after inserting the module:

[Thu Sep 7 14:34:20 2023] usbcore: registered new interface driver ax88179_178a

and modprobe output:

elsaco@eleven:~$ sudo modprobe -v ax88179_178a
insmod /lib/modules/5.15.90.4-microsoft-standard-WSL2/kernel/drivers/net/usb/ax88179_178a.ko
elsaco@eleven:~$ lsmod
Module                  Size  Used by
ax88179_178a           28672  0

@pdgendt
Copy link
Author

pdgendt commented Sep 8, 2023

@elsaco thanks for the response, I'll try that out, but I was hoping to be able to do it without replacing the kernel itself.
Getting updates from Windows to the WSL subsystem wouldn't affect the kernel anymore, and this would be something I tend to forget 🙃

@ghost
Copy link

ghost commented Sep 12, 2023

As elsaco has said, this is by design, until the kernel we ship changes to accommodate this.

@ghost ghost added the feature label Sep 12, 2023
@ghost ghost changed the title Unable to load driver from modules Feature request: Support for loadable kernel modules Sep 12, 2023
@ghost ghost mentioned this issue Sep 12, 2023
2 tasks
@qawsed90
Copy link

qawsed90 commented Dec 21, 2023

This problem does not occur when module building with CBL-Mariner 2.0 on docker. (Note: Module-dependent features must already be enabled in the kernel itself)
CONFIG_DEBUG_INFO_BTF is enabled in 5.10.74.3, CONFIG_DEBUG_INFO_BTF_MODULES is enabled in 5.15.57.1 and kernel and modules from a different build, which causes this error.
build_wsl_modules.zip containing the Dockerfile and build scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants