Skip to content

fix(attestation): keep enclave exit hooks local in EMU - #246

Open
Haitao Huang (haitaohuang) wants to merge 2 commits into
microsoft:integrationfrom
haitaohuang:user/hhuang/azurelinux3-emu-exit-hooks
Open

Haitao Huang (haitaohuang) wants to merge 2 commits into
microsoft:integrationfrom
haitaohuang:user/hhuang/azurelinux3-emu-exit-hooks

Conversation

@haitaohuang

@haitaohuang Haitao Huang (haitaohuang) commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Localize the enclave atexit and __cxa_atexit stubs in the application-only libservtd_attest_app.a. This avoids a duplicate atexit definition with glibc's libc_nonshared.a and lets host exit callbacks use libc.
  • Leave the firmware libservtd_attest.a unchanged.
  • Rescan libc after the late native archives in both hosted build scripts, so GNU ld resolves static OpenSSL's atexit reference as well as LLD does.
  • Add a native regression for C/C++ exit callbacks, archive integrity, repeatability, and fatal objcopy failures; run it in the EMU workflow and local gauntlet.

Validation

  • Native regression passed on Ubuntu 24.04 and Azure Linux 3.0.
  • Full local CI gauntlet passed in Azure Linux 3.0 with Rust 1.95: all six stages, 32 image builds, and 18 EMU scenarios, including CoRIM migration/rebind and the required revoked-policy rejection.
  • Reproduced the original glibc 2.38 linker failure and verified that the fix runs host exit callbacks without changing the firmware archive.
  • Reproduced the GNU ld ordering failure, then verified the actual emitted linker directives with -fuse-ld=bfd -nodefaultlibs and built the real hosted binary with -C linker-features=-lld.

Localize the enclave atexit and __cxa_atexit definitions in the application-only archive. This avoids glibc's duplicate atexit definition and preserves native process-exit callbacks without altering the firmware archive.

Add native regression coverage for callbacks, archive integrity, repeatability, and objcopy failure handling in CI and the local gauntlet.

Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
Assisted-by: Copilot:gpt-6-astra
Copilot-Session: a093a474-2f2c-42b1-97e5-7477359fb7bd
@haitaohuang

Copy link
Copy Markdown
Collaborator Author

The GitHub GNU ld jobs exposed an additional archive-ordering dependency that the local LLD run did not: the late static libcrypto needs libc rescanned after its atexit reference. I reproduced this locally with a regression that reads both build scripts’ emitted library order and links with GNU ld plus -nodefaultlibs. Adding -lc after the native archives fixes that regression, and the real hosted binary now builds with GNU ld. Full local revalidation is running before the corrective update is pushed.

Rescan libc after the hosted native archives in both build scripts. GNU ld otherwise leaves static OpenSSL's late atexit reference unresolved after the enclave exit stubs are localized.

Exercise the actual emitted library order with GNU ld and -nodefaultlibs in the native regression, rather than relying on LLD's archive rescanning.

Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
Assisted-by: Copilot:gpt-6-astra
Copilot-Session: a093a474-2f2c-42b1-97e5-7477359fb7bd
@haitaohuang

Copy link
Copy Markdown
Collaborator Author

The corrective head 0817b81 is fully validated. All pull-request workflows passed, and the extra push-run job that hit a transient OpenSSL download TLS failure also passed on retry. All 116 check runs are now successful. Local verification also passed the complete gauntlet, the real GNU-linked hosted build, and the native regression for library ordering, exit callbacks, archive integrity, and failure propagation.

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.

1 participant