Stock VKERNEL64 platform does not build: kern_mib.c's __build_id_start/__build_id_end are unresolvable β vkernel64's SYSTEM_LD override drops ${ELDFLAGS} (--build-id=sha1) and never uses the platform ldscript
Summary
Found at rig-build time: make nativekernel KERNCONF=VKERNEL64 fails at link (undefined __build_id_start/__build_id_end) - the SYSTEM_LD override links with a plain cc line that neither passes ELDFLAGS nor uses -T with the platform ldscript (proven dead by patching the PROVIDE block into it). The platform has been unbuildable since the build-id change and kern.build_id cannot exist on vkernel. defsym workaround fix validated (clean link, boots, passes the DF-5472/5473 rig).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-5474 Β· 9 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | β | 1.0 KB | β raw | |
| VERDICT.md | β | 2.8 KB | β raw | |
| verdict.json | β | 3.2 KB | view raw | |
| fix.diff | β | 604 B | view raw | |
| vk_build2.log | β | 25.6 KB | view raw | |
| vk_build3.log | β | 502 B | view raw | |
| vk_build5.log | β | 298.8 KB | β download | |
| vk_fixbuild2.log | β | 935.2 KB | β download | |
| env.txt | β | 250 B | view raw |
DF-5474 β vkernel64 platform does not build: kern_mib __build_id_* unresolved (SYSTEM_LD drops ELDFLAGS and never uses the platform ldscript)
File: sys/platform/vkernel64/x86_64/db_trace.c audit, discovered at rig build time Severity: Low (build regression / platform availability) Β· Confidence: certain
See VERDICT.md. Stock make nativekernel KERNCONF=VKERNEL64 fails at
linking kernel.debug with undefined __build_id_start/__build_id_end:
kern.pre.mk:135 adds --build-id=sha1 for all kernels, kern_mib.c references
the boundary symbols, pc64 provides them via its ldscript, vkernel64's
SYSTEM_LD override (conf/Makefile:23-25) drops ${ELDFLAGS} and its own
ldscript is dead (vk_build3.log). fix.diff: defsym both symbols to 0 in
SYSTEM_LD (kern_mib then returns ENOENT gracefully). Validated: link + boot.
Build/run:
cd /usr/src && make nativekernel KERNCONF=VKERNEL64 # stock: fails (vk_build2.log) patch -p1 < fix.diff && make nativekernel KERNCONF=VKERNEL64 # links (vk_fixbuild2.log)
DF-5474 VERDICT β reproduced (build failure), fix validated by link+boot
Bottom line: The stock VKERNEL64 platform cannot build on this tree:
sys/conf/kern.pre.mk:135 adds -Wl,--build-id=sha1 to ELDFLAGS for every
kernel and sys/kern/kern_mib.c:101-102 references __build_id_start /
__build_id_end, which are PROVIDE'd only by the pc64 linker script
(sys/platform/pc64/conf/ldscript.x86_64:74-77). The vkernel64 platform
overrides SYSTEM_LD (sys/platform/vkernel64/conf/Makefile:23-25) with a
plain cc -Wl,--export-dynamic -o kernel.debug ... -pthread link that
neither passes ${ELDFLAGS} nor uses the platform ldscript
(sys/platform/vkernel64/conf/ldscript.x86_64 is not referenced by any
link), so the two externs can never resolve:
vk_build2.log: /usr/src/sys/kern/kern_mib.c:111: error: undefined reference to '__build_id_end' /usr/src/sys/kern/kern_mib.c:111: error: undefined reference to '__build_id_start' /usr/src/sys/kern/kern_mib.c:132: error: undefined reference to '__build_id_start' collect2: error: ld returned 1 exit status *** [kernel.debug] Error code 1
vk_build3.log proves the platform ldscript is dead: patching the same
.note.gnu.build-id PROVIDE block into it changes nothing (same undefined
references), because SYSTEM_LD never passes -T.
Impact: build-regression / platform availability (nobody can have built
vkernel64 since the build-id change); kern.build_id is a security-relevant
sysctl (build provenance), and vkernel silently has none. Severity Low,
confidence certain.
Fix validated
fix.diff: append
-Wl,--defsym,__build_id_start=0 -Wl,--defsym,__build_id_end=0 to the
vkernel SYSTEM_LD line. kern_mib.c's sysctl then computes sectionlen 0 and
returns ENOENT gracefully (kern_mib.c:124-127). Validated on the guest:
make nativekernel KERNCONF=VKERNEL64 with the patched conf/Makefile links
cleanly (vk_fixbuild2.log: linking kernel.debug β size line, RC=0), the
resulting vkernel boots to single-user (vkrun_fixed.log) and behaves
correctly under the DF-5472/5473 rig. An alternative upstream-shaped fix is
to give vkernel64 a real build-id via its ldscript + -T, but that changes
link mode for a userland-executable kernel and was not attempted here.
Reproduce
cd /usr/src && make nativekernel KERNCONF=VKERNEL64 # stock: link error (vk_build2.log) patch -p1 < fix.diff # defsym in conf/Makefile make nativekernel KERNCONF=VKERNEL64 # links + boots
Fix status (batch validation)
Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.
Fix verification
fixedwith the defsym line in conf/Makefile, config+make nativekernel KERNCONF=VKERNEL64 links kernel.debug successfully and the vkernel boots to single-user; without it the link fails deterministically
findings/poc/DF-5474/vk_build2.log (failure), findings/poc/DF-5474/vk_fixbuild2.log (linking kernel.debug -> size line, RC=0), findings/poc/DF-5474/fix.diff (git apply --check clean)
Confirmed kernel references
- sys/conf/kern.pre.mk:135
- sys/kern/kern_mib.c:101
- sys/kern/kern_mib.c:111
- sys/kern/kern_mib.c:132
- sys/platform/pc64/conf/ldscript.x86_64:74
- sys/platform/vkernel64/conf/Makefile:23
- sys/platform/vkernel64/conf/ldscript.x86_64
Detail
Evidence (decisive lines)
vk_build2.log (stock link failure, undefined __build_id_*), vk_build3.log (ldscript patch proves it unused), vk_build5.log + vk_fixbuild2.log (defsym fix -> clean link), vkrun_fixed.log (fixed vkernel boots; DF-5472/5473 rig re-run on it)
PoC changes
n/a β finding discovered while building the DF-5472/5473 rig: the stock platform build failed before any rig code was involved
Verified recommended fix
append -Wl,--defsym,__build_id_start=0 -Wl,--defsym,__build_id_end=0 to SYSTEM_LD in sys/platform/vkernel64/conf/Makefile (or provide a real build-id via the platform ldscript)
Verdict
The stock VKERNEL64 platform cannot link on this tree: kern.pre.mk:135 adds -Wl,--build-id=sha1 to ELDFLAGS for all kernels and kern_mib.c:101-102/111/132 references __build_id_start/__build_id_end, which only the pc64 ldscript PROVIDEs (pc64/conf/ldscript.x86_64:74-77). vkernel64's SYSTEM_LD override (vkernel64/conf/Makefile:23-25) neither passes ${ELDFLAGS} nor uses the platform ldscript (proven dead: patching the PROVIDE block into it changes nothing, vk_build3.log), so the stock build fails at 'linking kernel.debug' with undefined references (vk_build2.log). Build-regression: the platform has been unbuildable since the build-id change, and the security-relevant kern.build_id provenance sysctl cannot exist on vkernel. Fixed and validated: appending -Wl,--defsym,__build_id_start=0 -Wl,--defsym,__build_id_end=0 to SYSTEM_LD links cleanly (vk_fixbuild2.log, RC=0) and the resulting vkernel boots and behaves (kern_mib.c:124-127 turns the 0-length into a graceful ENOENT).
No comments yet.