Skip to content

ci: stop rcodesign finalizing and unloading the PKCS#11 module - #295

Draft
sreya wants to merge 1 commit into
mainfrom
rcodesign-skip-module-finalize
Draft

sreya wants to merge 1 commit into
mainfrom
rcodesign-skip-module-finalize

Conversation

@sreya

@sreya sreya commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

rcodesign can die with SIGSEGV after it has written its signed output. This has failed three signing builds in coder/coder, which applies the same patch to rcodesign and uses the same Cloud KMS library. It has not happened in this repository yet. This is the same change as coder/coder#32333, and the patch file is byte-identical to the one there.

The patch made rcodesign call C_Finalize once signing was done and drop the module context, which unloads the library. When the Cloud KMS library authenticates with Google credentials, C_Finalize returns with most of the library's threads still running, and a thread that runs after the library is unmapped faults.

The module context now stays in the process-wide registry until the process exits, so the library is neither finalized nor unloaded. That is the one way the patch now differs from indygreg/apple-platform-rs#350, and its header says so.

No pull request job runs this action or the signing scripts, so the first real run is the preview build on main after the merge. That build currently fails before it signs, at Google authentication (44160625560), so it will not exercise this change until that is fixed.

The crash reproduces locally with scripts/signing/sign-app.sh and libkmsp11 1.9 against a fake Cloud KMS over TLS, with an external_account credential of the kind google-github-actions/auth writes. Both binaries were built with the action's commands and toolchain:

rcodesign built with sign-app.sh runs Segfaults sign-installer.sh runs Segfaults
the patch on main 40 16 40 0
this patch 40 0 40 0

All 16 crashes were in the two calls that sign the mutagen agents, after writing Mach-O was logged. With this patch the app and the installer still sign correctly: all 15 programs carry the signing certificate and no other, the installer's signature verifies, and against a SoftHSM token the signatures have the same identifiers, flags, entitlements and requirements as those the current patch produces.

Note

An AI agent (Xum) wrote this change for @sreya and ran the local tests above.

rcodesign can die with SIGSEGV after it has written its signed output.
This has failed signing builds in coder/coder, which applies the same
patch and uses the same Cloud KMS library. It has not happened in this
repository yet.

The patch made rcodesign call C_Finalize once signing was done and drop
the module context, which unloads the library. When the Cloud KMS
library authenticates with Google credentials, most of its threads are
still running at that point, so one of them can run after the library
is unmapped.

The module context now stays in the process-wide registry until the
process exits, so the library is neither finalized nor unloaded. The
patch file is the one in coder/coder#32333.
@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

SEC-1615

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants