From 62c5793bffc76005750a4473ccf8ecb751feb8ed Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 04:26:16 +0100 Subject: [PATCH] Run the packaged loader against original release executables --- tests/FEED.md | 2 ++ tests/exec-linkage.py | 67 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/FEED.md b/tests/FEED.md index 20188dc..eaf8d6c 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -154,3 +154,5 @@ On both targets, the worker installed musl and the public key package, then asse Changing the netbase archive after signing caused assembly to fail its signed index checksum check before exposing the output root. The rejection log in `foundation/offline-stage-rejection-01` has receipt manifest SHA-256 `e15be9b8ba76c5c115a622e7fa57997c1bcb9ca99a3319e18b3daf489ecc3c8d`. The installed-root auditor checks each nonempty ELF load segment against the released kernel page size, 4 KiB on x86_64 and 16 KiB on aarch64. It also checks required symbol-version namespaces against the actual resolved package-owned provider using GNU readelf and objdump. The 106-package x86_64 root and the corrected arm64 loader passed. An old arm64 BusyBox failed its segment congruence check. An x86_64 libcrypto with its original SONAME and a changed version tag failed the OpenSSL consumer check. See `foundation/load-and-versions-02`, receipt SHA-256 `fd32f6b69db215ff6b79ec1f58c8457cf7f514dd162fbde410d9f6882072b979`. Use `tests/exec-linkage.py` as well to exercise actual dynamic symbol resolution. + +To exercise the original release binaries against the installed libraries on a worker of the same architecture, run `python3 tests/exec-linkage.py "$arch" "$client" "$auditor" --proot "$proot" --release "$archive" "$sha256" "$report"`. The probe binds one original executable over its guest path and runs the installed musl loader with `--list`. A negative control changed a library import in the original input and verified that the installed loader diagnosed the changed SONAME. In the 129-package x86_64 root, 52 of 95 dynamic image executables relocated, 27 reported failures and 16 fixed-address executables needed direct execution. Twelve of 17 X11 sidecar executables relocated. See `foundation/release-binary-relocation-02`, receipt SHA-256 `8483666ef4294f1ac5d44c1eb637a8f5200be4e613e635d835ef4f86e7ffa37b`. Directly starting the release `cpp` and `cc1` in that root expanded `__SIZEOF_POINTER__` to 8. See `foundation/release-original-exec-02`, receipt SHA-256 `b9f1659e4669df9f3d4aeddea37fd9b85abc40f9d55045fff1fc7096f091a209`. diff --git a/tests/exec-linkage.py b/tests/exec-linkage.py index 570847a..355e115 100644 --- a/tests/exec-linkage.py +++ b/tests/exec-linkage.py @@ -1,10 +1,15 @@ """Use the installed musl loader to relocate each dynamic executable in a signed root.""" import argparse +import csv +import hashlib import os from pathlib import Path import shlex +import shutil import struct import subprocess +import tarfile +import tempfile def interpreter(path): @@ -49,8 +54,64 @@ def commands(arch, sdk): yield [loader, "--list", "/" + path.relative_to(root).as_posix()] +def release_probe(args): + archive, expected, report = args.release + with Path(archive).open("rb") as source: + if hashlib.file_digest(source, "sha256").hexdigest() != expected: + raise ValueError("release archive checksum mismatch") + root = args.client / "root" + loader = f"/lib/ld-musl-{args.arch}.so.1" + rows = [] + with tempfile.TemporaryDirectory() as folder, tarfile.open(archive, "r|gz") as members: + program = Path(folder) / "program" + program.touch(mode=0o755) + for entry in members: + if not entry.isfile(): + continue + with members.extractfile(entry) as member: + magic = member.read(4) + if magic != b"\x7fELF": + continue + with program.open("wb") as out: + out.write(magic) + shutil.copyfileobj(member, out) + interp = interpreter(program) + if interp is None: + continue + path = Path(entry.name.removeprefix("./")) + if path.is_absolute() or ".." in path.parts or ":" in str(path) or "!" in str(path): + raise ValueError(f"invalid guest bind path: {path}") + if interp != loader: + rows.append((str(path), "other interpreter", interp)) + continue + # Bind only the original program at its release path. Dependencies + # and the interpreter come from the independently audited root. + result = subprocess.run([args.proot, "-r", root, "-w", "/", "-b", f"{program}:/{path}!", + loader, "--list", "/" + str(path)], capture_output=True, text=True) + diagnostic = " | ".join(result.stderr.splitlines()) + status = "failed" if result.returncode else "relocated" + with program.open("rb") as source: + kind, = struct.unpack_from("