Skip to content

fix(runc): backport upstream fixes to build without Go crypto - #19869

Open
Muhammad Falak R Wani (mfrw) wants to merge 1 commit into
4.0from
mfrw/runc-zero-crypto-cgroups
Open

Muhammad Falak R Wani (mfrw) wants to merge 1 commit into
4.0from
mfrw/runc-zero-crypto-cgroups

Conversation

@mfrw

@mfrw Muhammad Falak R Wani (mfrw) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

runc init enters the container's mount namespace before the Go runtime starts, so the Microsoft Go systemcrypto backend dlopens libcrypto.so from the container rootfs. Every exec into an image without it fails (opencontainers/runc#4916). 4.0 works around this by building runc with MS_GO_NOSYSTEMCRYPTO=1, which opts runc out of the default crypto backend.

runc performs no cryptography. In 1.5.2 its only Go crypto imports come from two vendored helpers that runc never calls, and upstream has removed both:

Vendored module Change Upstream
go-selinux v1.13.1 use math/rand/v2 rather than crypto/rand opencontainers/selinux@9a2bcdd5c41a, released in v1.14.0
cgroups v0.1.0 drop the cilium/ebpf/asm dependency, which imports crypto/sha1 opencontainers/cgroups@d652a099305c (cgroups#94), merged on 2026-11-18, not yet released

This PR backports both to the vendored sources, so runc links no Go crypto. It drops the MS_GO_NOSYSTEMCRYPTO opt-out and fails the build if a future runc update links Go crypto again. Because runc no longer links any Go crypto, the Go runtime never needs libcrypto.so inside the container, so the other option raised in review (having it look at the host filesystem instead) isn't needed. The backports can go once runc vendors go-selinux v1.14.0 or later and a cgroups release that includes d652a099305c.

Changes

  • base/comps/runc/overlays/0001-backport-upstream-no-crypto.overlay.toml (upstream-backport): adds the two vendor patches and applies them after the vendor tarball is unpacked (%goprep -A, then %autopatch -p1).
    • 0001-vendor-go-selinux-use-math-rand-v2.patch: the upstream go-selinux commit, limited to the vendored selinux_linux.go.
    • 0002-vendor-cgroups-devices-drop-cilium-ebpf-asm-dependency.patch: the upstream cgroups commit, with paths under vendor/. The test hunk is dropped because the vendored tree has no tests. The resulting devicefilter.go and ebpf_linux.go are byte-identical to upstream.
  • base/comps/runc/overlays/0002-fail-build-on-go-crypto.overlay.toml (azl-security-compliance): %build fails if go tool nm finds any Go crypto package in the runc binary.
  • Removes 0001-disable-ms-go-systemcrypto.overlay.toml, so runc builds with the default Azure Linux Go configuration. Lock refreshed and spec re-rendered: runc 2:1.5.2-6.

Testing

  • azldev comp build (aarch64) of runc: success. %check passed (13 Go packages, 0 failures), and so did the new no-crypto check.

  • Binary: no Go crypto symbols (1.5.2-5 has 207) and no reference to libcrypto.so. cilium/ebpf is no longer linked, go version -m no longer shows GOEXPERIMENT=nosystemcrypto, and the binary is 4.9% smaller.

  • Containers on cgroup v2 (Fedora 43 VM), busybox rootfs without libcrypto:

    runc build run exec device filter
    1.5.2-4 (systemcrypto, no opt-out) ok fails: procReady not received, opensslcrypto: can't initialize OpenSSL libcrypto.so –
    1.5.2-5 (current 4.0, opt-out) ok ok /dev/zero allowed, host disk denied (EPERM)
    1.5.2-6 (this PR) ok ok /dev/zero allowed, host disk denied (EPERM)
  • azldev comp update and comp render are idempotent on the committed state; the commit message matches the commitizen schema; editorconfig-checker passes on the changed files.

@mfrw
Muhammad Falak R Wani (mfrw) requested a review from a team as a code owner November 2, 2026 17:07
Copilot AI balanced review requested due to automatic review settings November 2, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The security-sensitive eBPF encoder requires human verification of supported-architecture RPM builds, privileged cgroup-v2 allow/deny tests, and runc exec without libcrypto using default Microsoft Go, which this review environment cannot perform.

No open issues 🎉

What changed in this PR

This PR changes Azure Linux’s runc packaging to avoid Go crypto dependencies while retaining the default Microsoft Go crypto backend, addressing startup failures in containers without libcrypto.so.

Changes:

  • Backports go-selinux’s switch to math/rand/v2 and replaces cilium’s device-filter assembler with a local encoder.
  • Removes the systemcrypto opt-out and adds a build-time check for linked Go crypto packages.
  • Applies vendor patches after unpacking vendor sources and refreshes the lock and rendered packaging files.
File Description
specs/​r/​runc/​runc.spec Updates patch application, crypto guard, release, and changelog.
specs/​r/​runc/​0002-vendor-opencontainers-cgroups-encode-device-filter.patch Rendered patch introducing the local device-filter encoder.
specs/​r/​runc/​0001-vendor-go-selinux-use-math-rand-v2.patch Rendered SELinux random-number backport.
locks/​runc.lock Refreshes the component input fingerprint.
base/​comps/​runc/​overlays/​0001-disable-ms-go-systemcrypto.overlay.toml Removes the previous crypto-backend opt-out.
base/​comps/​runc/​overlays/​0001-build-runc-without-go-crypto.overlay.toml Registers vendor patches and the crypto-linkage guard.
base/​comps/​runc/​0002-vendor-opencontainers-cgroups-encode-device-filter.patch Replaces cilium assembly with local instruction encoding.
base/​comps/​runc/​0001-vendor-go-selinux-use-math-rand-v2.patch Replaces vendored SELinux’s crypto/rand dependency.

Review effort: Balanced

@christopherco Christopher Co (christopherco) left a comment •

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.

Marking this as draft while we discuss the RFC.

There are at least two paths I see:

  1. See if upstream runc already has plans to remove crypto packages. If so, the path this PR is taking could be offered
  2. The issue itself is that Go runtime starts after runc init has entered the container mount namespace, so the container's filesystem is referenced when Go is configured to use systemcrypto. This path would be to make Go look at the host's filesystem, which arguably should be used. This path should also be discussed with the runc community to gauge interest

@christopherco
Christopher Co (christopherco) marked this pull request as draft November 7, 2026 02:40
runc init enters the container's mount namespace before the Go runtime
starts, so the Microsoft Go systemcrypto backend dlopens libcrypto.so
from the container rootfs, and every exec into an image without it
fails (opencontainers/runc#4916). Azure Linux has worked around this by
building runc with MS_GO_NOSYSTEMCRYPTO=1, which opts runc out of the
default crypto backend.

runc performs no cryptography. In 1.5.2 its only Go crypto imports come
from two vendored helpers that runc never calls, and upstream has
removed both:

- go-selinux: use math/rand/v2 rather than crypto/rand
  (opencontainers/selinux 9a2bcdd5c41a, released in v1.14.0)
- cgroups: drop the cilium/ebpf/asm dependency, which imports
  crypto/sha1 (opencontainers/cgroups d652a099305c, merged on
  2026-11-18 as cgroups#94 and not yet released)

Backport both to the vendored sources so runc links no Go crypto, drop
the MS_GO_NOSYSTEMCRYPTO opt-out, and fail the build if a future runc
update links Go crypto again. The backports can go once runc vendors
go-selinux v1.14.0 or later and a cgroups release with d652a099305c.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 08:55
@mfrw

Copy link
Copy Markdown
Member Author

Marking this as draft while we discuss the RFC.

There are at least two paths I see:

  1. See if upstream runc already has plans to remove crypto packages. If so, the path this PR is taking could be offered

I did create an Issue there and the upstream community accepted the proposal.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Security-sensitive device-filter and crypto-startup changes require maintainer validation because RPM build/inspection and container exec/device-access smoke tests were unavailable.

No open issues 🎉

Review effort: Balanced

@mfrw Muhammad Falak R Wani (mfrw) added the 4.0 Issues and PRs for Azure Linux 4.0 label Nov 18, 2026
@mfrw Muhammad Falak R Wani (mfrw) changed the title RFC: fix(runc): encode device filter without cilium crypto fix(runc): backport upstream fixes to build without Go crypto Nov 18, 2026
@mfrw
Muhammad Falak R Wani (mfrw) marked this pull request as ready for review November 18, 2026 09:00
@mfrw

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 Issues and PRs for Azure Linux 4.0 targets-4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants