[DO NOT MERGE] [POC] fix(kernel): re-enable selftests package build#17045
Draft
rlmenge wants to merge 6 commits intotomls/base/mainfrom
Draft
[DO NOT MERGE] [POC] fix(kernel): re-enable selftests package build#17045rlmenge wants to merge 6 commits intotomls/base/mainfrom
rlmenge wants to merge 6 commits intotomls/base/mainfrom
Conversation
Disable kernel selftests as a temporary mitigation while kselftests packaging is fixed separately, and bump azl_pkgrelease to avoid reusing the previous NVR for a changed package set.
… Linux stage2 Temporary LLVM workaround kept on this branch only to unblock local kernel selftests investigation. Do not merge this commit with the kernel selftests fixes.
The kernel-selftests-internal RPM was missing test_progs and test_progs-no_alu32 because their build silently failed. Root cause: building test_ksyms_weak.lskel.h runs 'bpftool gen skeleton -L test_ksyms_weak.bpf.o', which loads the BPF program through libbpf. libbpf probes /proc/kallsyms to resolve __ksym __weak symbols. mock 6.7's systemd-nspawn build chroot blocks /proc/kallsyms reads (EACCES), so the lskel header is never generated and the test_progs / test_progs-no_alu32 link step fails. The kernel spec then tolerates the missing binaries with 'cp ... || true' on the install hooks, so the failure is invisible until you check what's actually packaged. Fix: in %prep, drop test_ksyms_weak.c from LSKELS_EXTRA in the BPF selftests Makefile and remove the matching subtest from prog_tests/ksyms_btf.c so the file still compiles without test_ksyms_weak.lskel.h. This mirrors the upstream Fedora fix 'selftests/bpf: Remove ksyms_weak_lskel test' by Artem Savkov which is referenced in kernel.spec's changelog but not present in the 6.18.5 source tree we pull from microsoft/CBL-Mariner-Linux-Kernel. Verified by inspecting the resulting kernel-selftests-internal RPM contents: test_progs, test_progs-no_alu32, urandom_read, and urandom_read-no_alu32 are now packaged, and 'test_progs --help' runs cleanly in a mock smoke test.
Many kselftest binaries (timens/, exec/, firmware/, mount/, vDSO/, ...)
were failing to link with errors like:
ld: relocation R_X86_64_32 against '.rodata.str1.1' can not be used
when making a PIE object; recompile with -fPIE
and silently getting omitted from kernel-selftests-internal because
the kernel spec uses 'cp ... || true' on the install hooks.
Root cause: Azure Linux's redhat-hardened-cc1 spec adds -fPIE to
compile and -pie to link by default. The kernel selftests Makefile
passes -fPIE down via EXTRA_CFLAGS, but many per-test Makefiles do
'CFLAGS := -Wall ...' which fully resets CFLAGS and drops the
inherited -fPIE. The link step then runs with -pie but objects
compiled without -fPIE, producing R_X86_64_32 relocations that PIE
links can't accept.
Fix: pass USERCFLAGS=-fPIE on the kselftests make line.
tools/testing/selftests/lib.mk does 'CFLAGS += $(USERCFLAGS)'
AFTER the per-test CFLAGS reset, so -fPIE is reliably re-added for
every selftest target.
Verified by inspecting the resulting kernel-selftests-internal RPM:
the previously-missing vdso_test_*, gettime_perf, set-exec, and
fw_namespace binaries are now packaged. Smoke-tested in mock:
'file vdso_test_abi' reports 'ELF 64-bit LSB pie executable' and
'vdso_test_abi' runs cleanly with valid TAP output.
The exec selftests install script-exec.inc and script-noexec.inc with a /usr/bin/env inc shebang. RPM's dependency generator turns those into Requires: /usr/bin/inc, but the inc helper is shipped inside kernel-selftests-internal under /usr/libexec/kselftests/exec/inc, not as a system interpreter. Filter /usr/bin/inc in __requires_exclude alongside liburandom_read.so.* so kernel-selftests-internal can be installed into images after the PIE fix makes the exec samples build and package successfully.
🔒❌ Lock files are out of dateFIX: — run this and commit the result: azldev component update -p llvm -p opencryptokiOr download the fix patch and apply it: gh run download 25409408457 -R microsoft/azurelinux -n locks-patch
git apply locks.patchChanged components (2)
|
📄❌ Rendered specs are out of dateFIX: — run this and commit the result: azldev component render llvmOr download the fix patch and apply it: gh run download 25409408457 -R microsoft/azurelinux -n rendered-specs-patch
git apply rendered-specs.patch
Content diffs`specs/l/llvm/llvm.spec`--- committed/specs/l/llvm/llvm.spec
+++ rendered/specs/l/llvm/llvm.spec
@@ -3527,13 +3527,8 @@
%changelog
## START: Generated by rpmautospec
-<<<<<<< HEAD
* Thu Apr 30 2026 Daniel McIlvaney <damcilva@microsoft.com> - 21.1.8-5
- feat: introduce deterministic commit resolution via Azure Linux lock file
-=======
-* Tue Apr 28 2026 azldev <azurelinux@microsoft.com> - 21.1.8-5
-- Latest state for llvm
->>>>>>> 554641f25f (fix(llvm): correct clang's default GCC triple for Azure Linux stage2)
* Thu Jan 22 2026 Josh Stone <jistone@redhat.com> - 21.1.8-4
- Fix s390x vector miscompilation (rhbz#2430017)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-staticsubpackages, etc.) have had theirReleasetag incremented../cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json)./LICENSES-AND-NOTICES/SPECS/data/licenses.json,./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md,./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)*.signatures.jsonfilessudo make go-tidy-allandsudo make go-test-coveragepassSummary
This patchset fixes the kernel selftests build and packaging path end-to-end. The main goal is to make
kernel-selftests-internalbuild reliably, include the expected selftest binaries, and remain installable in images.The failures were a chain rather than a single bug:
-fPIEby resettingCFLAGS, then failed to link under Azure Linux's hardened PIE-by-default toolchain.Requires: /usr/bin/incfrom selftest-local scripts, makingkernel-selftests-internaluninstallable in images.Patch Order
1.
fix(kernel): drop BPF lskel variant of test_ksyms_weaktest_progsandtest_progs-no_alu32were missing fromkernel-selftests-internalbecause the BPF selftests build failed while generatingtest_ksyms_weak.lskel.h.That light-skeleton path asks libbpf/bpftool to resolve weak kernel symbols. In the mock systemd-nspawn build chroot,
/proc/kallsymsreads are blocked withEACCES, which is expected container hardening: kallsyms exposes kernel symbol information and should not be available to an unprivileged build container.Because the header generation failed, the BPF
test_progsbinaries did not link, and the spec's permissive install hooks allowed the missing binaries to go unnoticed until RPM contents were inspected.The patch removes the optional light-skeleton variant of
test_ksyms_weak:test_ksyms_weak.cfromLSKELS_EXTRAtest_weak_syms_lskelsubtesttest_ksyms_weak.lskel.hincludeThis mirrors the Fedora-side fix noted in the kernel changelog while keeping the rest of the BPF selftests enabled.
2.
fix(kernel): pass USERCFLAGS=-fPIE to kselftests for hardened toolchainAzure Linux's hardened toolchain links executables as PIE by default. For PIE linking to succeed, C objects also need to be compiled with PIE-compatible code generation, normally
-fPIE.Many selftest Makefiles reset
CFLAGSwith assignments like:CFLAGS := ...That drops inherited hardening flags. The link step still uses PIE defaults, so affected tests fail with relocation errors such as:
The patch adds:
to the kselftests make invocation.
tools/testing/selftests/lib.mkappends$(USERCFLAGS)after per-testCFLAGSresets, so-fPIEsurvives consistently across the selftest tree.This caused previously missing vDSO, exec, firmware, mount, timens, and BPF-related selftest binaries to build and package correctly.
3.
fix(kernel): filter bogus inc selftest dependencyAfter the PIE fix, the exec selftests successfully installed additional files, including:
These scripts use:
RPM's shebang dependency generator interpreted that as:
That dependency is bogus for the selftests package. The
inchelper is shipped insidekernel-selftests-internalat:It is not a system interpreter provided by
/usr/bin/inc. The generated dependency madekernel-selftests-internaluninstallable in images.The patch extends the existing requires filter from:
to:
This keeps the package installable without hiding a real external dependency.
Change Log
Does this affect the toolchain?
NO
Associated issues
Test Methodology
Validation
Build/package validation
kernel-selftests-internal-6.18.5-1.8.azl4.x86_64was produced.test_progs,test_progs-no_alu32, vDSO tests, exec tests, and firmware tests./usr/bin/incRPM dependency was filtered.Image/VM validation
vm-baseimage withkernel-selftests-internalincluded for validation.kernel-selftests-internalwas installed on the VM./usr/libexec/kselftestscontained the expected test collections and 772 executable files.Kselftest smoke results on Azure VM
Medium suite results:
vDSOtimensexeccheck-exec-tests.shfailedfirmwarebpfExtended BPF-only run completed 13 top-level BPF tests before the wall-clock cap:
test_tagtest_mapstest_lru_maptest_sockmaptest_tcpnotify_usertest_kmod.shtest_tc_edt.shtest_verifiertest_progstest_progs-no_alu32test_progs-cpuv4test_lirc_mode2.shtest_tc_tunnel.shThe important packaging validation is that the large BPF binaries now build, install, and run. The remaining BPF failures appear to be runtime/test-environment issues, especially repeated module load failures such as:
That is likely related to module loading/signing/permission behavior on the VM rather than the original build or packaging failures.