Skip to content

Fix ARM64 light-mode JIT reading below the stack pointer - #365

Open
thomasbuilds wants to merge 1 commit into
tevador:masterfrom
thomasbuilds:fix-arm64-light-stack-read
Open

thomasbuilds wants to merge 1 commit into
tevador:masterfrom
thomasbuilds:fix-arm64-light-stack-read

Conversation

@thomasbuilds

Copy link
Copy Markdown
Contributor

In light mode, the ARM64 JIT computes each Dataset item into a 96-byte stack frame, frees the frame with add sp, sp, 96, and only then reads the item. AAPCS64 has no red zone so a signal delivered in between can overwrite the item and produce a wrong hash. FreeBSD, NetBSD and OpenBSD write their signal frame right below sp; Linux only overwrites the item when large SVE or SME state extends the frame; macOS keeps a 128-byte red zone and isn't affected.

This reserves the 96 bytes once in the prologue instead, by growing the existing str x0, [sp, -16]! to str x0, [sp, -112]! (and the epilogue's ldr to match), so the item stays allocated until it is read.

@thomasbuilds
thomasbuilds marked this pull request as draft October 22, 2026 16:50
@thomasbuilds
thomasbuilds force-pushed the fix-arm64-light-stack-read branch from 74b5364 to 553f312 Compare October 22, 2026 16:57
@thomasbuilds
thomasbuilds marked this pull request as ready for review October 22, 2026 16:58
@thomasbuilds

Copy link
Copy Markdown
Contributor Author

(ci failures are unrelated to my change)

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