Package: linux-kbuild-7.1.3+deb14
Version: 7.1.3-1
Tags: patch
X-Debbugs-Cc: [email protected], [email protected]
Dear Maintainer,
/usr/lib/linux-kbuild-7.1.3+deb14/scripts/gen-btf.sh invokes pahole
via plain variable expansion:
${PAHOLE} -J ${PAHOLE_FLAGS} \
${BTF_BASE:+--btf_base ${BTF_BASE}} \
--btf_encode_detached=${btf1} \
"${ELF_FILE}"
On Debian, PAHOLE is set to an awk wrapper command containing embedded
single quotes (it appends ",c++,c++11" to any --lang_exclude argument).
POSIX shell does not re-parse quoting inside expanded variables, so awk
receives the literal token 'BEGIN as part of its program text and
aborts:
awk: cmd. line:1: 'BEGIN
awk: cmd. line:1: ^ invalid char ''' in expression
The script's cleanup trap then removes the intermediate BTF files, and
the module link fails at Makefile.modfinal:62:
make[4]: *** [.../scripts/Makefile.modfinal:62: <module>.ko] Error 1
make[4]: *** Deleting file '<module>.ko'
This breaks the final link of every out-of-tree module built against
the 7.1.3 headers on systems where PAHOLE is the awk wrapper. I hit it
with the nvidia DKMS modules while working on #1136776, but the failure
is independent of any particular module: all module code had compiled
successfully and only the BTF post-processing step failed. The script
ships in linux-kbuild and is reached during DKMS builds via the
scripts/ symlink in linux-headers-7.1.3+deb14-common, so the failure
surfaces as a headers/module problem despite originating here — easy to
misattribute to the module being built.
The failure only manifests when BTF generation actually runs, i.e. when
a vmlinux is available for --btf_base; the script skips gracefully
otherwise, which may be why this has gone unnoticed.
The attached patch wraps the pahole invocation in eval so the shell
re-parses the embedded quoting. All inputs to the evaluated string
originate from the kernel build system, not from user-controlled data.
The resolve_btfids invocation is left untouched, as RESOLVE_BTFIDS is a
plain program path.
Tested on 7.1.3+deb14-amd64: with the fix applied, nvidia.ko,
nvidia-modeset.ko, nvidia-drm.ko, nvidia-uvm.ko and nvidia-peermem.ko
all link successfully with BTF sections generated, and the modules
load and run.
Regards,
Emre Uyguroğlu
-- System Information:
Debian Release: forky/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.12.17-amd64 (SMP w/32 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages linux-kbuild-7.1.3+deb14 depends on:
ii libc6 2.42-17
ii libelf1t64 0.195-1
ii libssl3t64 3.6.3-1
ii pahole 1.31-2
ii zlib1g 1:1.3.dfsg+really1.3.2-3
linux-kbuild-7.1.3+deb14 recommends no packages.
linux-kbuild-7.1.3+deb14 suggests no packages.
-- no debconf information
--- a/scripts/gen-btf.sh
+++ b/scripts/gen-btf.sh
@@ -69,11 +69,10 @@
gen_btf_data()
{
btf1="${ELF_FILE}.BTF.1"
- ${PAHOLE} -J ${PAHOLE_FLAGS} \
- ${BTF_BASE:+--btf_base ${BTF_BASE}} \
- --btf_encode_detached=${btf1} \
- "${ELF_FILE}"
-
+ eval "${PAHOLE} -J ${PAHOLE_FLAGS} \
+ ${BTF_BASE:+--btf_base ${BTF_BASE}} \
+ --btf_encode_detached=${btf1} \
+ '${ELF_FILE}'"
${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_FLAGS} \
${BTF_BASE:+--btf_base ${BTF_BASE}} \
--btf ${btf1} "${ELF_FILE}"