Skip to content

Support 16 KiB code signature pages on arm64 - #358

Open
chess-oai wants to merge 1 commit into
indygreg:mainfrom
chess-oai:codex/arm64-signature-pages-upstream
Open

chess-oai wants to merge 1 commit into
indygreg:mainfrom
chess-oai:codex/arm64-signature-pages-upstream

Conversation

@chess-oai

Copy link
Copy Markdown

Summary

rcodesign currently uses 4 KiB code-signature pages for every Mach-O. For large arm64 executables, this can make macOS signature verification slow: a 240 MB executable had 58,176 code slots at 4 KiB, compared with 14,544 at 16 KiB.

In a profile of codesign --verify --strict on the 4 KiB executable, 2,220 of 2,432 main-thread samples were in read(), under CodeDirectory::multipleHashFileData. Apple's SecStaticCode::validateExecutable opens the executable with F_NOCACHE and hashes each code slot separately. The profile shows read-heavy validation; it does not establish the underlying cause of each read's latency.

Add --arm64-16k-code-pages to opt arm64 Mach-O binaries into 16 KiB signature pages. The signer uses the selected size for both the code hashes and signature-size reservation. The 4 KiB default remains unchanged, as does the page size for other architectures. On the test machine, Apple's codesign also used 16 KiB by default for this arm64 executable.

On macOS 26.7, using ad hoc signed copies of the same executable, strict verification of fresh APFS clones took:

Signer and target 4 KiB 16 KiB
Apple codesign, bundle 4.69s, 4.54s (mean 4.61s) 1.51s, 1.69s (mean 1.60s)
Patched rcodesign, standalone executable 2.75s, 2.95s (mean 2.85s) 1.24s, 1.24s (mean 1.24s)

Each comparison used two runs per page size, in 4 KiB, 16 KiB, 16 KiB, 4 KiB order. The ad hoc rcodesign code directory shrank from approximately 1.86 MB to 0.47 MB. All 85 existing library tests pass with PKCS#11 enabled.

@ofek

ofek commented Oct 7, 2026

Copy link
Copy Markdown

@indygreg Can you please press the button to allow CI to run? Note that this patch is being used successfully by Astral.

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.

2 participants