Skip to content

workaround(azurelinux-release): bind-mount /proc/version for CBL-Mariner compat#16446

Merged
christopherco merged 1 commit intotomls/base/mainfrom
rlmenge/tomls/proc-version
Apr 4, 2026
Merged

workaround(azurelinux-release): bind-mount /proc/version for CBL-Mariner compat#16446
christopherco merged 1 commit intotomls/base/mainfrom
rlmenge/tomls/proc-version

Conversation

@rlmenge
Copy link
Copy Markdown
Contributor

@rlmenge rlmenge commented Apr 3, 2026

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

Extensions grep /proc/version for "Mariner" to detect the OS. AZL no longer includes that string since it builds with Fedora's kernel toolchain.

Add a systemd oneshot service that generates a /proc/version override at boot, replacing the user@host field with "root@CBL-Mariner-azurelinux", and bind-mounts it over /proc/version. This preserves the real kernel version, compiler string, and build timestamp while satisfying legacy detection logic.

The service runs early (before walinuxagent and cloud-init) and only activates inside VMs (ConditionVirtualization=vm).

Change Log
  • workaround(azurelinux-release): bind-mount /proc/version for CBL-Mariner compat
Associated issues
Test Methodology
  • Pipeline build id: 971055

@rlmenge rlmenge marked this pull request as ready for review April 3, 2026 01:57
Copilot AI review requested due to automatic review settings April 3, 2026 01:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an Azure Linux–side workaround to preserve compatibility with legacy tooling that greps /proc/version for “Mariner”, by generating a modified version string at boot and bind-mounting it over /proc/version in VM environments.

Changes:

  • Add a proc-version-override oneshot systemd service and helper script that generates and bind-mounts an override for /proc/version.
  • Ship and enable the new unit by default via the azurelinux-release package (spec + systemd preset updates).
  • Bump azurelinux-release Release and add a changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
base/comps/azurelinux-release/proc-version-override.sh Adds script to generate an override string and bind-mount it over /proc/version.
base/comps/azurelinux-release/proc-version-override.service Adds oneshot unit intended to run early in VMs and manage the bind mount lifecycle.
base/comps/azurelinux-release/azurelinux-release.spec Packages the new unit + script and bumps release/changelog.
base/comps/azurelinux-release/90-default.preset Enables the new service by default via presets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@christopherco christopherco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a general suggestion for an alternate pattern, but overall this workaround does work for us. :shipit:

Comment on lines +36 to +40
install -m 0444 /dev/null "$OVERRIDE"
cat > "$OVERRIDE" <<EOF
Linux version ${KVER} (root@CBL-Mariner-azurelinux) ${TAIL}
EOF
chmod 0444 "$OVERRIDE"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): While this will work as a workaround for the issue we are facing, keep in mind a different pattern to write to a temp file, do an atomic move operation, then chmod 444 the final file. Readers reading the $OVERRIDE while it is being written could read partial content. Not an issue here since this one-shot service will run well before the guest extension runs, but something to keep in mind for future

@christopherco
Copy link
Copy Markdown
Collaborator

Actually, checking the commits, these need to be squashed into 1 commit so the final merged git history looks proper after the rebase-merge. I'll handle that

…ner compat

Extensions grep /proc/version for "Mariner" to detect
the OS. AZL no longer includes that string since it builds with
Fedora's kernel toolchain.

Add a systemd oneshot service that generates a /proc/version override at
boot, replacing the user@host field with "root@CBL-Mariner-azurelinux",
and bind-mounts it over /proc/version. This preserves the real kernel
version, compiler string, and build timestamp while satisfying legacy
detection logic.

The service runs early (before walinuxagent and cloud-init) and only
activates inside VMs (ConditionVirtualization=vm).

Hardened proc-version-override service:
- Fix shebang to #!/bin/bash for portability
- Add idempotent mount handling: unwind stacked mounts with
  while-findmnt loop before rebinding
- Make override file read-only (0444) and remount bind as ro
- Use dash-prefixed ExecStop/ExecStopPost for robust cleanup
  on stop (umount + rm override file)
@christopherco christopherco force-pushed the rlmenge/tomls/proc-version branch from 8e3732d to 91fad25 Compare April 4, 2026 05:24
@christopherco christopherco merged commit 23a1605 into tomls/base/main Apr 4, 2026
5 of 6 checks passed
@christopherco christopherco deleted the rlmenge/tomls/proc-version branch April 4, 2026 05:24
@binujp
Copy link
Copy Markdown
Contributor

binujp commented Apr 4, 2026

Apologies for the late comment, did not see this go by. While the bind mount mechanism works it is rather kludgy. There is an accepted upstream method to do this via KBUILD_BUILD_USER and KBUILD_BUILD_HOST. Maybe this was discussed and we had reasons to not use them. In that case I would first try patching mkcompile_h and other build time mechanisms before going with runtime overrides.

https://www.kernel.org/doc/html/latest/kbuild/reproducible-builds.html is a good reference.

@christopherco
Copy link
Copy Markdown
Collaborator

Apologies for the late comment, did not see this go by. While the bind mount mechanism works it is rather kludgy. There is an accepted upstream method to do this via KBUILD_BUILD_USER and KBUILD_BUILD_HOST. Maybe this was discussed and we had reasons to not use them. In that case I would first try patching mkcompile_h and other build time mechanisms before going with runtime overrides.

https://www.kernel.org/doc/html/latest/kbuild/reproducible-builds.html is a good reference.

We briefly touched on this KBuild method initially, specifically debating whether we should temporarily hardcode our kernel build string, or do a per-app bind-mount method. We ended up going with the bind-mount method because /proc/version is currently outputting the proper information about the actual builder environment that the kernel is built in, and that is the correct behavior. Certain software that is scraping /proc/version and changing their logic based on string search of specific key words ("Mariner" in this case) in the builder information is what really needs to be updated, as that software shouldn't condition code paths based on non-deterministic kernel build-host information.

That being said, we were hoping to bind-mount at a per-app level, rather than system-wide, to allow non-misbehaving software to actually see the correct /proc/version. Since we ended up going with a system-wide method due to late-found impracticalities of the per-app method, we should re-evaluate just setting KBUILD_BUILD_HOST and removing the bind-mount kludge for better consistency. Will discuss it this week.

cc: @rlmenge

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.

4 participants