Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #93336 > unrolled thread

Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules

Started byEmre Uyguroğlu <uyguremre@hotmail.com>
First post2026-07-13 10:00 +0200
Last post2026-07-13 13:50 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.debian.kernel


Contents

  Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules Emre Uyguroğlu <uyguremre@hotmail.com> - 2026-07-13 10:00 +0200
    Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules Bastian Blank <waldi@debian.org> - 2026-07-13 13:50 +0200
      Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules Bastian Blank <waldi@debian.org> - 2026-07-13 15:40 +0200
    Processed: Re: Bug#1141979: gen-btf.sh: quoting in PAHOLE awk  wrapper breaks BTF step for all out-of-tree modules "Debian Bug Tracking System" <owner@bugs.debian.org> - 2026-07-13 13:50 +0200
    Bug#1141979: marked as done (gen-btf.sh: quoting in PAHOLE awk  wrapper breaks BTF step for all out-of-tree modules) "Debian Bug Tracking System" <owner@bugs.debian.org> - 2026-07-13 13:50 +0200

#93336 — Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules

FromEmre Uyguroğlu <uyguremre@hotmail.com>
Date2026-07-13 10:00 +0200
SubjectBug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules
Message-ID<NgjK1-4sg4-1@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Package: linux-kbuild-7.1.3+deb14
Version: 7.1.3-1
Tags: patch
X-Debbugs-Cc: uyguremre@hotmail.com, 1136776@bugs.debian.org

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

[toc] | [next] | [standalone]


#93337

FromBastian Blank <waldi@debian.org>
Date2026-07-13 13:50 +0200
Message-ID<NgnkB-4u9J-5@gated-at.bofh.it>
In reply to#93336
Control: tags -1 unreproducible

On Mon, Jul 13, 2026 at 10:55:28AM +0300, Emre Uyguroğlu wrote:
> /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:

Sorry, but I can not reproduce this, please show a complete log, without
redactions.

| % cat foo.c 
| #include <linux/kernel.h>
| #include <linux/module.h>
| 
| static int __init foo_init(void)
| {
|         pr_info("foo initialised\n");
|         return 0;
| }
| module_init(foo_init);
| 
| static void __exit foo_exit(void)
| {
| }
| module_exit(foo_exit);
| 
| MODULE_LICENSE("GPL");
| MODULE_DESCRIPTION("");

| % cat Kbuild 
| obj-m += foo.o

| % make -C /lib/modules/7.1.3+deb14-amd64/build M=$(pwd) V=1
[…]
| # BTF [M] foo.ko
|   if [ ! -f /usr/src/linux-headers-7.1.3+deb14-amd64/vmlinux ]; then printf "Skipping BTF generation for %s due to unavailability of vmlinux
| " foo.ko 1>&2; else sh /usr/src/linux-headers-7.1.3+deb14-common/scripts/gen-btf.sh --btf_base /usr/src/linux-headers-7.1.3+deb14-amd64/vmlinux foo.ko; fi;
| + trap cleanup EXIT
| + BTFGEN_MODE=vmlinux
| + [ -n /usr/src/linux-headers-7.1.3+deb14-amd64/vmlinux ]
| + BTFGEN_MODE=module
| + gen_btf_data
| + btf1=foo.ko.BTF.1
| + pahole -J -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs --btf_features=attributes --btf_features=layout -j --lang_exclude=rust --btf_base /usr/src/linux-headers-7.1.3+deb14-amd64/vmlinux --btf_encode_detached=foo.ko.BTF.1 foo.ko
| + /usr/src/linux-headers-7.1.3+deb14-amd64/tools/bpf/resolve_btfids/resolve_btfids --distill_base --verbose --btf_base /usr/src/linux-headers-7.1.3+deb14-amd64/vmlinux --btf foo.ko.BTF.1 foo.ko
| Cannot find .BTF_ids or symbols sections, skip symbols resolution
| Dumped 8165 bytes of data to foo.ko.BTF
| Dumped 1626 bytes of data to foo.ko.BTF.base
| + embed_btf_data
| + x86_64-linux-gnu-objcopy --add-section .BTF=foo.ko.BTF foo.ko
| + btf_base=foo.ko.BTF.base
| + [ -f foo.ko.BTF.base ]
| + x86_64-linux-gnu-objcopy --add-section .BTF.base=foo.ko.BTF.base foo.ko
| + btf_ids=foo.ko.BTF_ids
| + [ -f foo.ko.BTF_ids ]
| + exit 0
| + cleanup
| + rm -f foo.ko.BTF.1
| + rm -f foo.ko.BTF
| + [ module = module ]
| + rm -f foo.ko.BTF.base
| + rm -f foo.ko.BTF_ids

As you see, it calls plain "pahole":
| + pahole -J -j […] foo.ko

And pahole is a real binary:
| % file $(command -v pahole)
| /usr/bin/pahole: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=da5fc94cd2e230bfc12d272357e681e8d4a505ad, for GNU/Linux 3.2.0, stripped

Bastian

-- 
A father doesn't destroy his children.
		-- Lt. Carolyn Palamas, "Who Mourns for Adonais?",
		   stardate 3468.1.

[toc] | [prev] | [next] | [standalone]


#93340

FromBastian Blank <waldi@debian.org>
Date2026-07-13 15:40 +0200
Message-ID<Ngp33-4v3L-1@gated-at.bofh.it>
In reply to#93337
On Mon, Jul 13, 2026 at 01:39:59PM +0200, Bastian Blank wrote:
> > 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:

This is nvidia stuff:
https://sources.debian.org/src/nvidia-open-gpu-kernel-modules/550.163.01-4/debian/patches/module/0062-Support-BTF-generation-for-non-release-builds.patch?hl=28#L28

Bastian

-- 
Not one hundred percent efficient, of course ... but nothing ever is.
		-- Kirk, "Metamorphosis", stardate 3219.8

[toc] | [prev] | [next] | [standalone]


#93338 — Processed: Re: Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules

From"Debian Bug Tracking System" <owner@bugs.debian.org>
Date2026-07-13 13:50 +0200
SubjectProcessed: Re: Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules
Message-ID<NgnkB-4u9J-11@gated-at.bofh.it>
In reply to#93336
Processing control commands:

> tags -1 unreproducible
Bug #1141979 [linux-kbuild-7.1.3+deb14] gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules
Added tag(s) unreproducible.

-- 
1141979: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1141979
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems

[toc] | [prev] | [next] | [standalone]


#93339 — Bug#1141979: marked as done (gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules)

From"Debian Bug Tracking System" <owner@bugs.debian.org>
Date2026-07-13 13:50 +0200
SubjectBug#1141979: marked as done (gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules)
Message-ID<NgnkB-4u9J-1@gated-at.bofh.it>
In reply to#93336

[Multipart message — attachments visible in raw view] — view raw

Your message dated Mon, 13 Jul 2026 13:44:05 +0200
with message-id <jh55pvwivsykmcuibdjn5nzoypqv47dnk6eqiglwd2cbxvf47r@xitc7iiqf3w2>
and subject line Re: Bug#1141979: gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules
has caused the Debian Bug report #1141979,
regarding gen-btf.sh: quoting in PAHOLE awk wrapper breaks BTF step for all out-of-tree modules
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1141979: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1141979
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.kernel


csiph-web