Bug#1114006: linux-source-6.12: Cannot build additional module for linux-image-6.12.41+deb13-rt-amd64
Source: linux-source-6.12
Severity: normal
Tags: ftbfs
X-Debbugs-Cc: debian-amd64@lists.debian.org
User: debian-amd64@lists.debian.org
Usertags: amd64
Dear Maintainer,
I installed linux-image-6.12.41+deb13-rt-amd64 on an embedded
platform. A required kvaser_pciefd device driver is missing; it is in
the linux source tree (drivers/net/can/kvaser_pciefd.c), but disabled
in .config. So I tried to build it separately, using instructions on:
https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html
https://imil.net/blog/posts/2022/build-a-single-in-tree-linux-kernel-module-debian--clones/
Attempted steps are:
<on development platform with trixie docker container>
sudo apt install linux-image-6.12.41+deb13-rt-amd64
sudo apt install linux-headers-6.12.41+deb13-rt-amd64
sudo apt install linux-source-6.12
tar xaf /usr/src/linux-source-6.12.tar.xz
cd linux-source-6.12/
cp /boot/config-6.12.41+deb13-rt-amd64 .config
cp /usr/src/linux-headers-6.12.41+deb13-rt-amd64/Module.symvers .
scripts/config --module CAN_KVASER_PCIEFD
make oldconfig scripts prepare modules_prepare
make -C . M=drivers/net/can
<copy to target>
sudo insmod kvaser_pciefd.ko
However, 'make oldconfig' requests for missing configuration options
(see below). A first attempt with the default options produces an
incompatible kernel module:
insmod: ERROR: could not insert module kvaser_pciefd.ko: Invalid module format
>From dmesg:
[69966.964063] kvaser_pciefd: version magic '6.12.41 SMP preempt_rt mod_unload modversions ' should be '6.12.41+deb13-rt-amd64 SMP preempt mod_unload modversions '
With these additional configuration changes, 'make oldconfig' remains
silent:
scripts/config --set-str BUILD_SALT '6.12.41+deb13-rt-amd64'
scripts/config --set-str LOCALVERSION '+deb13-rt-amd64'
scripts/config --disable PREEMPT_NONE
scripts/config --disable PREEMPT_VOLUNTARY
scripts/config --enable PREEMPT_BUILD
scripts/config --disable MODULE_SIG_ALL
scripts/config --set-str MODULE_SIG_KEY ''
scripts/config --set-str SYSTEM_TRUSTED_KEYS ''
However, the module still won't load:
[70821.323351] kvaser_pciefd: version magic '6.12.41+deb13-rt-amd64 SMP preempt_rt mod_unload modversions ' should be '6.12.41+deb13-rt-amd64 SMP preempt mod_unload modversions '
Note the 'preempt_rt' vs 'preempt' version magic.
The updated .config has quite some changes, notably:
-CONFIG_PREEMPT_BUILD=y
-CONFIG_ARCH_HAS_PREEMPT_LAZY=y
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT is not set
-CONFIG_PREEMPT_LAZY=y
-# CONFIG_PREEMPT_LAZIEST is not set
CONFIG_PREEMPT_RT=y
CONFIG_PREEMPT_COUNT=y
CONFIG_PREEMPTION=y
-CONFIG_PREEMPT_DYNAMIC=y
# CONFIG_SCHED_CORE is not set
# CONFIG_SCHED_CLASS_EXT is not set
(And probably as a result: -CONFIG_UNINLINE_SPIN_UNLOCK=y)
According to include/linux/vermagic.h, the lacking CONFIG_PREEMPT_BUILD
causes the version magic difference. An (ugly) work-around is to use:
echo '#define CONFIG_PREEMPT_BUILD 1' >> include/generated/autoconf.h
This produces a loadable kernel module (so the bug title is a bit
exaggerated), although it causes the kernel to be tainted (not
unexpected):
[71610.769100] kvaser_pciefd: loading out-of-tree module taints kernel.
[71610.769391] kvaser_pciefd: module verification failed: signature and/or required key missing - tainting kernel
I would expect that building a module from the linux-source package is
supported (hence this bug report), but please correct me if I'm wrong.
Note that I also tried to build the kernel (including the module) from
the deb source ('apt source linux-image-6.12.41+deb13-rt-amd64-unsigned'),
but the resulting kernel has a different symbol layout and hence the
module cannot be loaded by the original kernel.
Thanks!
Roel
PS. Enabling CAN_KVASER_PCIEFD by default would be helpful as well of
course :-)
'make oldconfig' output:
*
* Restart config...
*
*
* General setup
*
Compile also drivers which will not load (COMPILE_TEST) [N/y/?] n
Compile the kernel with warnings as errors (WERROR) [N/y/?] n
Local version - append to kernel release (LOCALVERSION) []
Automatically append version information to the version string (LOCALVERSION_AUTO) [N/y/?] n
Build ID Salt (BUILD_SALT) [] (NEW)
Kernel compression mode
1. Gzip (KERNEL_GZIP)
2. Bzip2 (KERNEL_BZIP2)
3. LZMA (KERNEL_LZMA)
4. XZ (KERNEL_XZ)
5. LZO (KERNEL_LZO)
6. LZ4 (KERNEL_LZ4)
> 7. ZSTD (KERNEL_ZSTD)
choice[1-7?]: 7
Default init path (DEFAULT_INIT) []
Default hostname (DEFAULT_HOSTNAME) [(none)] (none)
System V IPC (SYSVIPC) [Y/n/?] y
POSIX Message Queues (POSIX_MQUEUE) [Y/n/?] y
General notification queue (WATCH_QUEUE) [N/y/?] n
Enable process_vm_readv/writev syscalls (CROSS_MEMORY_ATTACH) [Y/n/?] y
uselib syscall (for libc5 and earlier) (USELIB) [Y/n/?] y
Auditing support (AUDIT) [Y/?] y
Preemption Model
1. No Forced Preemption (Server) (PREEMPT_NONE) (NEW)
2. Voluntary Kernel Preemption (Desktop) (PREEMPT_VOLUNTARY) (NEW)
3. Preemptible Kernel (Low-Latency Desktop) (PREEMPT)
> 4. Fully Preemptible Kernel (Real-Time) (PREEMPT_RT)
choice[1-4?]:
Core Scheduling for SMT (SCHED_CORE) [N/y/?] n
Extensible Scheduling Class (SCHED_CLASS_EXT) [N/y/?] n
CPU isolation (CPU_ISOLATION) [Y/?] y
Kernel .config support (IKCONFIG) [N/m/y/?] n
Enable kernel headers through /sys/kernel/kheaders.tar.xz (IKHEADERS) [N/m/y/?] n
Kernel log buffer size (16 => 64KB, 17 => 128KB) (LOG_BUF_SHIFT) [17] 17
CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB) (LOG_CPU_MAX_BUF_SHIFT) [12] 12
Printk indexing debugfs interface (PRINTK_INDEX) [N/y/?] n
Checkpoint/restore support (CHECKPOINT_RESTORE) [Y/n/?] y
Automatic process group scheduling (SCHED_AUTOGROUP) [N/y/?] n
Kernel->user space relay support (formerly relayfs) (RELAY) [Y/?] y
Initial RAM filesystem and RAM disk (initramfs/initrd) support (BLK_DEV_INITRD) [Y/n/?] y
Initramfs source file(s) (INITRAMFS_SOURCE) []
Support initial ramdisk/ramfs compressed using gzip (RD_GZIP) [Y/n/?] y
Support initial ramdisk/ramfs compressed using bzip2 (RD_BZIP2) [Y/n/?] y
Support initial ramdisk/ramfs compressed using LZMA (RD_LZMA) [Y/n/?] y
Support initial ramdisk/ramfs compressed using XZ (RD_XZ) [Y/n/?] y
Support initial ramdisk/ramfs compressed using LZO (RD_LZO) [Y/n/?] y
Support initial ramdisk/ramfs compressed using LZ4 (RD_LZ4) [Y/n/?] y
Support initial ramdisk/ramfs compressed using ZSTD (RD_ZSTD) [Y/n/?] y
Boot config support (BOOT_CONFIG) [N/y/?] n
Preserve cpio archive mtimes in initramfs (INITRAMFS_PRESERVE_MTIME) [Y/n/?] y
Compiler optimization level
> 1. Optimize for performance (-O2) (CC_OPTIMIZE_FOR_PERFORMANCE)
2. Optimize for size (-Os) (CC_OPTIMIZE_FOR_SIZE)
choice[1-2?]: 1
Enable madvise/fadvise syscalls (ADVISE_SYSCALLS) [Y/n/?] y
Enable membarrier() system call (MEMBARRIER) [Y/?] y
Enable kcmp() system call (KCMP) [Y/?] y
Enable rseq() system call (RSEQ) [Y/n/?] y
Enable debugging of rseq() system call (DEBUG_RSEQ) [N/y/?] n
Enable cachestat() system call (CACHESTAT_SYSCALL) [Y/n/?] y
PC/104 support (PC104) [N/y/?] n
Load all symbols for debugging/ksymoops (KALLSYMS) [Y/?] y
Test the basic functions and performance of kallsyms (KALLSYMS_SELFTEST) [N/y/?] n
Include all symbols in kallsyms (KALLSYMS_ALL) [Y/n/?] y
Profiling support (PROFILING) [Y/n/?] y
*
* Enable loadable module support
*
Enable loadable module support (MODULES) [Y/n/?] y
Module debugging (MODULE_DEBUG) [N/y/?] n
Forced module loading (MODULE_FORCE_LOAD) [Y/n/?] y
Module unloading (MODULE_UNLOAD) [Y/n/?] y
Forced module unloading (MODULE_FORCE_UNLOAD) [Y/n/?] y
Tainted module unload tracking (MODULE_UNLOAD_TAINT_TRACKING) [N/y/?] n
Module versioning support (MODVERSIONS) [Y/n/?] y
Source checksum for all modules (MODULE_SRCVERSION_ALL) [N/y/?] n
Module signature verification (MODULE_SIG) [Y/?] y
Require modules to be validly signed (MODULE_SIG_FORCE) [N/y/?] n
Automatically sign all modules (MODULE_SIG_ALL) [Y/n/?] (NEW)
Hash algorithm to sign modules
1. SHA-1 (MODULE_SIG_SHA1)
> 2. SHA-256 (MODULE_SIG_SHA256)
3. SHA-384 (MODULE_SIG_SHA384)
4. SHA-512 (MODULE_SIG_SHA512)
5. SHA3-256 (MODULE_SIG_SHA3_256)
6. SHA3-384 (MODULE_SIG_SHA3_384)
7. SHA3-512 (MODULE_SIG_SHA3_512)
choice[1-7?]: 2
Module compression (MODULE_COMPRESS) [Y/n/?] y
Module compression type
1. GZIP (MODULE_COMPRESS_GZIP)
> 2. XZ (MODULE_COMPRESS_XZ)
3. ZSTD (MODULE_COMPRESS_ZSTD)
choice[1-3?]: 2
Automatically compress all modules (MODULE_COMPRESS_ALL) [Y/n/?] y
Support in-kernel module decompression (MODULE_DECOMPRESS) [Y/n/?] y
Allow loading of modules with missing namespace imports (MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS) [N/y/?] n
Path to modprobe binary (MODPROBE_PATH) [/sbin/modprobe] /sbin/modprobe
Trim unused exported kernel symbols (TRIM_UNUSED_KSYMS) [N/y/?] n
*
* Certificates for signature checking
*
File name or PKCS#11 URI of module signing key (MODULE_SIG_KEY) [certs/signing_key.pem] (NEW)
Type of module signing key to be generated
> 1. RSA (MODULE_SIG_KEY_TYPE_RSA)
choice[1]: 1
Provide system-wide ring of trusted keys (SYSTEM_TRUSTED_KEYRING) [Y/?] y
Additional X.509 keys for default system keyring (SYSTEM_TRUSTED_KEYS) [] (NEW)
Reserve area for inserting a certificate without recompiling (SYSTEM_EXTRA_CERTIFICATE) [N/y/?] n
Provide a keyring to which extra trustable keys may be added (SECONDARY_TRUSTED_KEYRING) [Y/n/?] y
Only allow additional certs signed by keys on the builtin trusted keyring (SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN) [N/y/?] n
Provide system-wide ring of blacklisted keys (SYSTEM_BLACKLIST_KEYRING) [Y/n/?] y
Hashes to be preloaded into the system blacklist keyring (SYSTEM_BLACKLIST_HASH_LIST) []
Provide system-wide ring of revocation certificates (SYSTEM_REVOCATION_LIST) [N/y/?] n
Allow root to add signed blacklist keys (SYSTEM_BLACKLIST_AUTH_UPDATE) [N/y/?] n
#
# configuration written to .config
#
-- System Information:
Debian Release: 13.0
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.16.3-200.fc42.x86_64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
-- no debconf information
Reply to: