Skip to content

linux, linux-esx: make canister_build work against the current kernel - #1675

Open
dcasota wants to merge 2 commits into
vmware:5.0from
dcasota:fix/canister-build-against-current-kernel
Open

linux, linux-esx: make canister_build work against the current kernel#1675
dcasota wants to merge 2 commits into
vmware:5.0from
dcasota:fix/canister-build-against-current-kernel

Conversation

@dcasota

@dcasota dcasota commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The problem

canister_build=1 fails in %prep against Photon 5.0's own current kernel. The canister-creation series is maintained against the certified kernel 6.12.60, and upstream has since dropped the WARN_ON() wrapper around !digest_size in pkcs1pad_verify():

// 6.12.60 — what the series expects
if (WARN_ON(req->dst) || WARN_ON(!digest_size) ||
// 6.12.103 — what is actually there
if (WARN_ON(req->dst) || !digest_size ||

rpm applies at --fuzz=0, so pure context drift is fatal:

+ rpmuncompress .../1004-Move-__bug_table-section-to-fips_canister_wrapper.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
1 out of 2 hunks FAILED -- saving rejects to file crypto/rsa-pkcs1pad.c.rej
error: Bad exit status from /var/tmp/rpm-tmp.2derUe (%prep)

It looks worse than it is

%prep stops at the first failure, so this reads like a diverged patch series. It is not. Applying 10001016 to the 6.12.103 tree and forcing through failures to see the whole picture:

16 of 18 applications succeed unmodified. The only two rejects are the same line, in the same function, in the same file — patch 1004 (which converts it) and patch 1010 (which carries it as context). With both hunks rebased, the series applies clean at --fuzz=0 with zero rejects.

Why 1004 matters beyond compiling

WARN_ON expands to a __bug_table entry, and 1004-Move-__bug_table-section-to-fips_canister_wrapper.patch exists specifically to keep __bug_table out of the canister. Leaving that call unconverted would embed a bug-table entry in the frozen blob.

Also: the version pins

Both canister version pins were bare %defines with no %{!?...} guard, so no build could be pointed at anything but the certified canister without editing the spec:

  • fips_canister_version (both flavours) — so a build can link a canister produced locally for the kernel under test.
  • fips_certified_kernel_version — so a build that creates a new canister can stamp the kernel it was really built from, rather than inherit a certification it does not carry. The spec's own comment already asked for this: "Remove below line when building a new canister."

linux-esx deliberately keeps canister_build 0. The canister is one artifact, built once and consumed by both flavours — which is exactly how the prebuilt path already works. Making the pin overridable is all that flavour needs.

Verification

  • Default build unchanged: resolves fips-canister-6.12.60-18.2.ph5.tar.bz2 exactly as before, so a normal build is byte-identical.
  • -D 'fips_canister_version 6.12.103-12.ph5' → both specs resolve the local canister.
  • -D 'canister_build 1'linux-fips-canister subpackage still emitted.
  • Rebased series applies clean at --fuzz=0, verified from a true pre-series tree (original 1004 reverse-applied first, so the result is not an artefact of the partial application).

Not verified

A full canister kernel build has not completed — the rebase was validated at patch and spec level. The %build-stage struct comparator (check_kernel_struct_in_canister.inc) has not been exercised against 6.12.103.

@dcasota
dcasota force-pushed the fix/canister-build-against-current-kernel branch 2 times, most recently from 5167f6a to 2110644 Compare September 2, 2026 08:10
@aabusair aabusair closed this Sep 2, 2026
@aabusair aabusair reopened this Sep 2, 2026
@dcasota
dcasota force-pushed the fix/canister-build-against-current-kernel branch 3 times, most recently from 7390b86 to 3a0b9a5 Compare September 3, 2026 16:36
dcasota and others added 2 commits September 7, 2026 14:09
…g.inc

linux.spec and linux-esx.spec implemented the same canister Kconfig handling
in two different idioms, and they disagreed on one constellation.

linux-esx.spec used %if 0%{?fips} / %else, and its %else branch cleaned the
GCC_PLUGIN_{MATCH,PAD}_CANISTER_STRUCTS comments out of .config. linux.spec
instead used two independent %if canister_build / %if canister_usage blocks
with no %else, so when fips=0 nothing ran: the shipped .config kept the
"is not set" comments, make olddefconfig dropped them, and the
check_for_config_applicability.inc diff guard failed %prep. That is the
generic aarch64 kernel - fips is set by %global inside %ifarch, so it is
unconditionally 1 on x86_64 and cannot be overridden with -D, and
acvp_build/kat_build force fips=1 even on aarch64.

Move the three conditional blocks into SPECS/linux/canister_config.inc,
pulled in by both specs as Source5 + %include, the same mechanism both
already use for check_for_config_applicability.inc. Divergence between the
two flavours is now impossible by construction.

linux-esx.spec additionally gains the derived-flag block linux.spec already
had (canister_build=0, canister_usage=fips), nested inside the existing
%if fips so it does not shadow -D. esx never builds a canister - it untars a
prebuilt one - so fips=1 implies canister_usage=1, reproducing the old
branch exactly.

Tested across 112 cells: 2 specs x {x86_64, aarch64} x subrelease {91, 92} x
14 flag combinations of fips / canister_build / canister_usage / acvp_build /
kat_build. All x86_64 cells are byte-identical apart from the release string.
The aarch64 fips=0 cells replace PR#14's broad sed with linux-esx's narrower
pair; the two forms produce byte-identical output on all five shipped config
files, because no config contains a CANISTER_STRUCTS=y form - only the
"is not set" comment form. The esx aarch64 reordering is likewise a no-op:
the canister and jitterentropy seds touch disjoint symbols.

Change-Id: If4107c14d8f15752dff0c0f25c6b4dee504e3041
Signed-off-by: Daniel Casota <dcasota@gmail.com>
canister_build could not build against the shipping kernel at all. %prep died
at --fuzz=0 with

    1 out of 2 hunks FAILED -- saving rejects to crypto/rsa-pkcs1pad.c.rej

Upstream dropped the WARN_ON() wrapper around !digest_size in
pkcs1pad_verify(), and that single line is context for both 1004 and 1010. In
1004 the conversion is not cosmetic: WARN_ON emits a __bug_table entry, and
keeping __bug_table out of the canister is the entire point of that patch.

Verified with rpmbuild -bp on a staged topdir: the whole series applies with
no rejects and pkcs1pad_verify() comes out as

    if (fcw_warn_on(req->dst) || !digest_size ||
        !ctx->key_size || sig_size != ctx->key_size ||
        pkcs1pad_invalid_hash_len(digest_size, digest_info))

Stacked on the canister_config.inc change, which took -12; this takes -13. The
two are stacked in fact, not just in numbering: a tree carrying only the
include refactor has a spec that claims canister support the patch series
cannot deliver.

An earlier version of this change also made fips_canister_version and
fips_certified_kernel_version overridable via a %{!?name: ...} guard. That is
dropped. rpm expands the guarded form correctly, but Photon's own SpecParser
does not: _isDefinition() matches only a line STARTING with %define/%global,
so the guard is invisible to it and ExtraBuildRequiresSansSnapshot kept
%{fips_canister_version} literal - the build then asked tdnf for a package
called "linux-fips-canister-%{fips_canister_version}" and both kernel flavours
failed to build. Overridability needs a mechanism that parser understands, and
is not needed for this fix.

Change-Id: Ifae87ab0fbfc289436a62b91bdfbff00e9d98b6c
Signed-off-by: Daniel Casota <dcasota@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JW73JTCUGRcaNTUEQcAMtf
@dcasota
dcasota force-pushed the fix/canister-build-against-current-kernel branch from 3a0b9a5 to 2590191 Compare September 7, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants