The pre-compiled binary blobs nv-kernel.o_binary and nv-modeset-kernel.o_binary shipped with driver 590.48.01 fail objtool validation on kernel 6.19 when CONFIG_MITIGATION_RETHUNK is enabled. The blobs were compiled without
-mfunction-return=thunk-extern and -mharden-sls=all, causing hundreds of errors during module linking.
Environment
- Driver version: 590.48.01
- OS: openSUSE Tumbleweed
- Kernel: 6.19.0-lowlatency-sunlight1
- GPU: NVIDIA GeForce RTX 3060 Laptop
- Architecture: x86_64
- Kernel config: CONFIG_MITIGATION_RETHUNK=y
- NVIDIA Proprietary driver + MIT/GPL driver
Build errors
The build fails at the composite module link step when objtool runs on nvidia.o and nvidia-modeset.o:
nvidia.o: error: objtool: sessionAddDependant_IMPL+0x86: ‘naked’ return found in MITIGATION_RETHUNK build
nvidia.o: error: objtool: serverAllocShareWithHalspecParent+0xbb: ‘naked’ return found in MITIGATION_RETHUNK build
nvidia.o: error: objtool: kgspGetBinArchiveGspRmBoot_TU102+0xb: ‘naked’ return found in MITIGATION_RETHUNK build
nvidia.o: error: objtool: libosLogInit+0xbe: ‘naked’ return found in MITIGATION_RETHUNK build
…
nvidia-modeset.o: error: objtool: nvstatusToString+0x3a: ‘naked’ return found in MITIGATION_RETHUNK build
nvidia-modeset.o: error: objtool: f32_div+0x8d: ‘naked’ return found in MITIGATION_RETHUNK build
…
make[4]: *** [scripts/Makefile.build:509: nvidia.o] Error 1
make[4]: *** [scripts/Makefile.build:509: nvidia-modeset.o] Error 1
Root cause
PR #1015 added -mfunction-return=thunk-extern and -mharden-sls=all to src/nvidia/Makefile and src/nvidia-modeset/Makefile, but the pre-compiled blobs shipped in the installer package were not rebuilt with these flags. The
blobs contain plain ret instructions instead of __x86_return_thunk calls, and objtool with --rethunk --werror rejects them.
Workaround
Adding the following to kernel-open/Kbuild and kernel/Kbuild skips objtool on composite module objects containing the blobs:
$(obj)/nvidia.o: private objtool := true
$(obj)/nvidia-modeset.o: private objtool := true
The driver loads and works correctly after this, but produces a runtime warning:
Unpatched return thunk in use. This should not happen!
WARNING: arch/x86/kernel/cpu/bugs.c:3737
Expected fix
The nv-kernel.o_binary and nv-modeset-kernel.o_binary blobs should be recompiled with -mfunction-return=thunk-extern and -mharden-sls=all so they pass objtool validation on kernels with CONFIG_MITIGATION_RETHUNK enabled,
without requiring the workaround above.