Repository navigation
CARRY: fix(konflux): stop static-glibc NSS crashes in the CLI, supervisor and sandbox images - #54
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: Comment |
andre-motta
left a comment
There was a problem hiding this comment.
Reviewed with the midstream scope in mind (RHEL 9 / UBI 9 only). The pin approach is sound: __nss_configure_lookup in glibc 2.34 forces the initial nsswitch.conf load, sets reload_disabled, and overwrites the per-database action list. Dropping +crt-static on the supervisor is safe since it runs from its own image in the Docker, Podman, and Kubernetes drivers.
One real ask (negative control on the probe) and a few hardening nits inline.
Separately, since this changes how openshell-sandbox links and initializes NSS, please do one manual smoke run of the built sandbox image on OpenShift and confirm that getaddrinfo to the gateway and getpwuid on a random OpenShift UID both work with the pin active. The synthetic getpwuid probe in the build does not exercise the real binary.
Static glibc binaries still read /etc/nsswitch.conf and dlopen() every NSS module other than the built-in files and dns (myhostname, resolve, systemd, sss). The module pulls the host's libc.so.6 into the process and the binary segfaults, both when the host glibc differs from the one we link (Fedora 44, UBI10, Debian, Ubuntu) and when it matches (UBI9). The CLI crashed resolving any gateway hostname missing from /etc/hosts on Fedora and RHEL workstations, and the supervisor's own ubi-minimal image ships the systemd NSS modules. Neither binary needs to be static. The supervisor always runs from its own image in the Kubernetes, Docker and Podman drivers, which is also how upstream builds it. The CLI runs on user hosts, where dynamic linking keeps host resolvers such as myhostname (*.localhost), resolve and sss working. The trade-off is that the CLI now needs glibc 2.34 or newer on the host (RHEL 9+, Fedora, current Debian and Ubuntu) and no longer runs on RHEL 8 or musl hosts. This partially reverts fa0130c for these two images: drop +crt-static and glibc-static, drop the CodeReady Builder repo and the glibc-static and libxcrypt-static lock entries, and fail the build if either binary comes out static. Related: RHAI-1927 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
…-sandbox openshell-sandbox has to stay static because drivers copy or mount it into arbitrary agent images, and it stays on glibc rather than musl because of RHEL-219374. Like any static glibc binary, it segfaults when a lookup reaches an NSS module listed in the image's /etc/nsswitch.conf. In stock UBI9, UBI10 and Fedora images that includes getpwuid() for a UID missing from /etc/passwd, such as an OpenShift random UID, and getgrouplist(). Link a small C constructor (deploy/konflux/sandbox/pin-nss.c) into the binary. It calls glibc's __nss_configure_lookup() before main() and limits every NSS database to files, plus dns for hosts and networks. Lookups then behave like upstream's musl build: users and groups come from /etc/passwd and /etc/group, and hosts from /etc/hosts and DNS. The override is per-process, so workloads the sandbox execs keep the image's normal NSS configuration. The pin lives in the Konflux build rather than in crate sources, so it adds no conflict surface for upstream syncs. The build fails if the pin is missing from the binary, or if it stops working. For the latter, a fake NSS module with no libc dependency (deploy/konflux/sandbox/nss-probe.c) answers every UID: a static probe without the pin must resolve an unknown UID through it (negative control), and the same probe linked with the pin must not. Closes RHAI-1927 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
…shell-cluster The troubleshooting entry for supervisor runtime validation told operators to check that supervisor_image contains a static /openshell-supervisor. The Konflux supervisor is now linked dynamically against the glibc in its own image, so require a supervisor from the matching release whose dynamic loader and shared libraries are available inside that image instead, and give a `--version` check that shows both. The separate requirement that /openshell-sandbox is static is unchanged. The wording matches the upstream fix byte for byte, so the next upstream sync merges cleanly and this carry can then be dropped. Related: RHAI-1927 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
cec2498 to
bce9d57
Compare
andre-motta
left a comment
There was a problem hiding this comment.
All four comments addressed at bce9d57. The fake-module negative control is a better design than the crash assertion I suggested, since it is deterministic across architectures and also fails when the module cannot load. The -nodefaultlibs correction on the --undefined flag is right; thanks for reproducing it. Checked the new nss-probe.c against the glibc _nss_*_getpwuid_r contract, confirmed the fake module and nsswitch.conf edit stay in the builder stage, and confirmed the supervisor supports --version for the SKILL.md check.
OpenShell v0.0.116-rhaiv.8+ rejects the legacy compute_drivers list in [openshell.gateway] with "unknown field `compute_drivers`", so the gateway never became healthy in the E2E job. Render compute_driver = "podman" instead. Bump OPENSHELL_IMAGE_TAG to v0.0.116-rhaiv.11, which carries the static-glibc NSS fix (opendatahub-io/openshell#54). The gateway only reads gateway.toml at startup, so setup() now tears down the sandbox and restarts a running gateway when the rendered config no longer matches the on-disk file, instead of reusing stale driver images. Co-Authored-By: Claude Opus <noreply@anthropic.com> Signed-off-by: Andre Lustosa <alustosa@redhat.com>
OpenShell v0.0.116-rhaiv.8+ rejects the legacy compute_drivers list in [openshell.gateway] with "unknown field `compute_drivers`", so the gateway never became healthy in the E2E job. Render compute_driver = "podman" instead. Bump OPENSHELL_IMAGE_TAG to v0.0.116-rhaiv.11, which carries the static-glibc NSS fix (opendatahub-io/openshell#54). The gateway only reads gateway.toml at startup, so setup() now tears down the sandbox and restarts a running gateway when the rendered config no longer matches the on-disk file, instead of reusing stale driver images. Co-Authored-By: Claude Opus <noreply@anthropic.com> Signed-off-by: Andre Lustosa <alustosa@redhat.com>
Summary
The Konflux CLI, supervisor and
openshell-sandboxbinaries segfault whenever a hostname, user or group lookup reaches an NSS module such asmyhostname,resolve,systemdorsss. This PR links the CLI and supervisor dynamically against glibc, and pins NSS to glibc's built-infiles/dnsservices in the staticopenshell-sandbox.Related Issue
Fixes RHAI-1927. This is downstream only: upstream ships the CLI and
openshell-sandboxas static musl and the supervisor as dynamic glibc, so it is not affected.Supersedes #53 (autofix), which takes the same approach but doesn't link on x86_64: its NSS object is compiled without
-fPIE. Details in the closing comment there.Root cause
Since
fa0130c0(first shipped inv0.0.102-rhaiv.0), these three binaries are static glibc (+crt-staticwith UBI9glibc-static2.34). Static glibc still reads/etc/nsswitch.confanddlopen()s every listed module other than the built-infilesanddns. The module pulls the host'slibc.so.6into the process, and the process crashes in both cases:DT_RELRrelocations, so the hostlibc.so.6dereferences an unrelocated pointer.2.34-275.el9_8on both sides): the module loads, but__tls_get_addrreturns NULL for its thread-local storage, and it crashes in_nss_systemd_is_blockedorsysctl_read.Reproducer from the report (no gateway needed).
0.0.116-rhaiv.10exits with 139 on Fedora 44:Changes
Three carries. The sandbox workaround can be reverted on its own if the sandbox ever moves off static glibc (for example once RHEL-219374 lands), and the docs fix can be dropped once upstream fixes the same line:
CARRY: fix(konflux): link CLI and supervisor dynamically against glibcDockerfile.konflux.cliandDockerfile.konflux.supervisor: drop+crt-staticandglibc-static. The build now fails if either binary comes out static.rpms.in.yaml: dropglibc-staticand the CodeReady Builder repo.rpms.lock.yaml: remove theglibc-staticandlibxcrypt-staticentries, the only CodeReady Builder packages. The edited package sets exactly match a freshrpm-lockfile-prototyperesolution on x86_64 and aarch64, so there is no unrelated version drift.CARRY: fix(konflux): pin NSS to built-in services in static openshell-sandboxdeploy/konflux/sandbox/pin-nss.c: a constructor that calls glibc's__nss_configure_lookup()beforemain()and limits every NSS database tofiles(files dnsfor hosts and networks), matching upstream's musl behavior. The override is per-process and doesn't surviveexec(), so agent workloads keep their image's NSS configuration.Dockerfile.konflux.sandbox: compile and link it with-C link-arg, plus-Wl,--undefined=__nss_configure_lookup. rustc links with-nodefaultlibsand puts link args after its own-lc, so without the flag the symbol only resolves because std's lookups already pulled it in. Two build guards: the pin must be present in the binary, and it must actually work. For the second,deploy/konflux/sandbox/nss-probe.cbuilds a fake NSS module with no libc dependency that answers every UID. A static probe without the pin must resolve an unknown UID through it (negative control, exit 1), and the same probe linked with the pin must not (exit 0). This is deterministic on x86_64 and aarch64 and doesn't depend onsystemd-libsbeing in the builder image.CARRY: docs(skills): stop requiring a static supervisor in debug-openshell-clusterskills/debug-openshell-cluster/SKILL.md: the supervisor runtime validation entry told operators to check for a static/openshell-supervisor. It now asks for a supervisor from the matching release whose dynamic loader and shared libraries are available inside its own image, and gives a check:docker run --rm --network none --entrypoint /openshell-supervisor <supervisor_image> --versionprints the release, and ano such file or directoryerror for a binary that exists means the loader or a library is missing. The separate requirement that/openshell-sandboxis static is unchanged. Upstream's supervisor is also dynamic, so the same line is stale upstream. The upstream fix, chore(build): remove stale static-supervisor leftovers ai-openshell/openshell#3520, uses byte-identical wording, so the next upstream sync merges cleanly and this carry can be dropped.Behavior change to note
The CLI binary now needs glibc 2.34 or newer on the host (RHEL 9+, Fedora, current Debian and Ubuntu). Extracted from the image, it no longer runs on RHEL 8 or musl hosts; the static build crashed on most hosts anyway. In return it honors the host's NSS configuration fully, so
*.localhostthroughmyhostname,resolveandsssall work. The alternative, a static CLI with the same NSS pin as the sandbox, would stay portable but lose those resolvers. Happy to switch if RHEL 8 hosts matter.Testing
Hermetic local builds of all three images (
deploy/konflux/build-local.sh,--network none, x86_64), with every build guard passing, plus:rhaiv.10).localhostresolves throughmyhostnamewhere configuredGLIBC_2.34; all resolve inubi-minimal:9.8--versionworks,DEFAULT:PQintact, entrypoint unchangedPT_INTERP; readsnsswitch.confonce beforemain(); loads nolibnss_*under stock Fedora 44 config; runs on UBI10, Alpine and Debianpin-nss.oin a static probe (unknown-UIDgetpwuid,getgrouplist,getaddrinfo)An independent adversarial review also ran a 25-call lookup matrix (passwd and group enumeration,
initgroups,AI_CANONNAME, reverse lookups,getservbyname, lookups in forked children) under a hostilensswitch.conf, with zerolibnss_*modules opened. It also covered missing and unreadablensswitch.conf, and aarch64 (qemu, static non-PIE).mise run pre-commit: passes except two checks that fail identically onmain.license:checkflags 21 existing Tekton and Konflux files without SPDX headers (the same list as CARRY: feat(konflux): enable post-quantum cryptography in images #38), andmarkdown:lintflagse2e/rust/tests/odh/AGENTS.md:36(MD038). Locally,license:checkalso needsSETUPTOOLS_SCM_PRETEND_VERSION, because the-rhaiv.Ntags don't parse as versions.mise run test: Rust 6,771 passed (workspace 5,045,openshell-server1,711, content-guard example 15), Python 254 passed, SBOM 10 passed. This PR changes no Rust code. In one full run, three timing-sensitive tests inopenshell-supervisor-network(proxy::tests::plaintext_*) timed out under load. They pass in isolation (the wholeproxy::testsmodule: 341 passed) and passed in the final full run.markdownlint-cli2 --no-globs skills/debug-openshell-cluster/SKILL.mdreports 0 errors. The repo'smarkdown:linttask doesn't globskills/, and still reports only the existingAGENTS.mdMD038.skillsaw lintreports the same findings before and after the edit; its one error, the skill's context budget, already exists onmain.--no-verify: the installed git hook runsmise run pre-commit, which fails only on the pre-existinglicense:checkfiles listed above.pinned probe exited 1when the pin object has no constructor; and it fails the negative control when the fake module is missing. The latest hermetic sandbox build passes all guards.tier1with a UBI-based agent image before merge.openshell-sandboxitself, which needs a driver-staged bootstrap.Checklist
CARRY:prefix🤖 Generated with Claude Code