me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Compare shipped library exports with source-built replacements

diviocity committed 5 days ago · c23f1a759c45eb3adceceabd3ab7a9b9e581c5c8 View patch
Unverified signature 2 files changed +90 -0
PROFILES.md +2 -0

@@ -105,3 +105,5 @@ The next clean x86_64 install resolved 129 signed packages in ten dependency sta

105105The x86_64 path fixture booted the published kernel with a 19-package signed root. It loaded Zsh's attribute, line-editor and completion modules, initialized completion, read the linux, alacritty and xterm-256color terminfo entries, found the indexed Misc Fixed bitmap font, and executed the target-prefixed GNU assembler and linker. The serial transcript is in `foundation/relocated-guest-x86-01`, receipt SHA-256 `c6b8615194003d7ee9490682127a0b2d477b35bac8d37282f97ac94e8bb4eeab`. A separate audit of the 129-package root ran the installed musl loader over all 158 dynamic executable paths on the x86_64 build worker. See `foundation/abi-desktop-129-01`, receipt SHA-256 `9b07bc02aa03c6c5a30411ec760865648f39297d6c270cd8f0e973165a37337b`.

106106

107107The x86_64 first-boot registration screen ran with a clean, 15-package vpac root and its packaged release PID 1. The test added the five native Vinix programs from the checksum-pinned release initramfs and checked their hashes inside the guest. The guest observed both the graphical session and the registration process, then sampled at least 24 colors from the 1024×768 framebuffer. Reproduce this with `tests/desktop-guest.py`. The worker retains the manifest and serial transcript in `foundation/desktop-registration-x86-01`, receipt SHA-256 `0f0a3bc88bbb2b4921df92510163a43afbaaf8f683b05fe8bf180a62f9888129`.

108+

109+`tests/library-upgrades.py` reads the actual shared libraries in the checksum-pinned release initramfs and the replacement files in an audited root. It checks the ELF target, SONAME, provider ownership and dynamic exports, including symbol versions and exported data sizes. PCRE2's two x86_64 libraries retained all 77 and 6 compared exports, and zlib retained all 95. Their new implementation filenames are in `foundation/release-library-interfaces-01/interfaces.tsv`, receipt SHA-256 `11ddb4daf9f4b2d231c512b3b9e16f92dd2ccdb1192fff0130a6be5037fa971b`. OpenSSL 3.5.9-3 retained all 580 libssl exports. Its libcrypto lacked the three published NIST prime-field method symbols for 224, 256 and 521 bits. See `foundation/release-ssl-interfaces-01/known-differences.sha256`, SHA-256 `679aab5f1a2d7d4beb4853872ba45b30a4b875c27fb70b5ca6ffa708340105ce`.

tests/library-upgrades.py new file +88 -0

@@ -0,0 +1,88 @@

1+"""Compare the release's shared-library interface to its package-owned replacement."""

2+import argparse

3+import csv

4+import hashlib

5+from pathlib import Path

6+import shutil

7+import subprocess

8+import tarfile

9+import tempfile

10+

11+

12+def interface(path, arch):

13+ report = subprocess.check_output(["readelf", "-W", "-h", "-d", "--dyn-syms", path], text=True)

14+ machine = "AArch64" if arch == "aarch64" else "Advanced Micro Devices X86-64"

15+ fields = [line.strip() for line in report.splitlines()]

16+ if not any(line.startswith("Machine:") and line.split(":", 1)[1].strip() == machine for line in fields):

17+ raise ValueError(f"unexpected ELF target in {path}")

18+ soname, = [line.split("[", 1)[1].split("]", 1)[0] for line in fields if "(SONAME)" in line]

19+ exports = set()

20+ for line in fields:

21+ row = line.split()

22+ if (len(row) >= 8 and row[0].endswith(":") and row[0][:-1].isdigit()

23+ and row[4] in ("GLOBAL", "WEAK", "UNIQUE") and row[5] in ("DEFAULT", "PROTECTED")

24+ and row[6] not in ("UND", "ABS")):

25+ kind = "FUNC" if row[3] in ("FUNC", "IFUNC") else row[3]

26+ exports.add((row[7], kind, row[2] if kind in ("OBJECT", "TLS") else ""))

27+ if not exports:

28+ raise ValueError(f"no exported dynamic symbols in {path}")

29+ return soname, exports

30+

31+

32+def run(args):

33+ with args.initramfs.open("rb") as source:

34+ if hashlib.file_digest(source, "sha256").hexdigest() != args.sha256:

35+ raise ValueError("release initramfs checksum mismatch")

36+ subprocess.run([args.auditor, args.arch, args.client], check=True)

37+ root = (args.client / "root").resolve()

38+ expected = {path: (package, soname) for package, path, soname in args.library}

39+ if len(expected) != len(args.library):

40+ raise ValueError("each release path must occur only once")

41+ results = {}

42+ with tempfile.TemporaryDirectory() as temp, tarfile.open(args.initramfs, "r|gz") as contents:

43+ for entry in contents:

44+ path = entry.name.removeprefix("./")

45+ if path not in expected:

46+ continue

47+ package, name = expected[path]

48+ if not entry.isfile() or path in results or Path(name).name != name:

49+ raise ValueError(f"expected one regular release library at {path}")

50+ reference = Path(temp) / "reference"

51+ with contents.extractfile(entry) as source, reference.open("wb") as copy:

52+ shutil.copyfileobj(source, copy)

53+ old_name, old = interface(reference, args.arch)

54+ alias = Path(path).with_name(name)

55+ current = (root / alias).resolve()

56+ current_path = current.relative_to(root)

57+ records = [d for d in (args.client / "db/local").glob("*/desc")

58+ if f"\n%NAME%\n{package}\n" in "\n" + d.read_text()]

59+ record, = records

60+ owned = set(record.with_name("files").read_text().splitlines())

61+ if alias.as_posix() not in owned or current_path.as_posix() not in owned:

62+ raise ValueError(f"{package} must own both {alias} and {current_path}")

63+ new_name, new = interface(current, args.arch)

64+ if old_name != name or new_name != name:

65+ raise ValueError(f"{path}: expected {name}, found {old_name} and {new_name}")

66+ missing = sorted(old - new)

67+ results[path] = (package, name, current_path, len(old), len(new), len(missing),

68+ ",".join(symbol for symbol, _, _ in missing))

69+ if set(results) != set(expected):

70+ raise ValueError(f"missing release libraries: {sorted(set(expected) - set(results))}")

71+ with args.output.open("x") as stream:

72+ table = csv.writer(stream, delimiter="\t", lineterminator="\n")

73+ table.writerow(("release_path", "package", "soname", "installed_path", "old_exports",

74+ "new_exports", "missing_count", "missing_symbols"))

75+ for path, result in sorted(results.items()):

76+ table.writerow((path, *result))

77+ return int(any(row[-2] for row in results.values()))

78+

79+

80+if __name__ == "__main__":

81+ parser = argparse.ArgumentParser(description=__doc__)

82+ parser.add_argument("arch", choices=("aarch64", "x86_64"))

83+ for arg in ("client", "auditor", "initramfs", "output"):

84+ parser.add_argument(arg, type=Path)

85+ parser.add_argument("sha256", help="published initramfs digest")

86+ parser.add_argument("--library", nargs=3, action="append", metavar=("PACKAGE", "RELEASE_PATH", "SONAME"),

87+ required=True)

88+ raise SystemExit(run(parser.parse_args()))