fix: ARM64 TPIDR_EL0, signal trampoline, and /dev/tty controlling terminal#235
Merged
fix: ARM64 TPIDR_EL0, signal trampoline, and /dev/tty controlling terminal#235
Conversation
…e syscall number Two ARM64 fixes that resolve DATA_ABORT crashes at FAR=0xffffffffffffff5c when running BusyBox ash shell and musl-linked programs: 1. TPIDR_EL0 (Thread Local Storage pointer) was never saved or restored during context switches. When multiple userspace processes share a CPU, they clobber each other's TLS pointer. musl libc stores errno and pthread structures via TPIDR_EL0, so a zeroed/wrong value causes accesses to addresses like 0 - 164 = 0xffffffffffffff5c. Added tpidr_el0 field to CpuContext and mrs/msr instructions in all 5 context switch paths: save_userspace, save_kernel, restore_kernel, restore_userspace, and setup_first_entry. Also preserved in from_aarch64_frame for fork inheritance. 2. Signal trampoline used x86_64 syscall number 15 for rt_sigreturn instead of the correct ARM64 number 139. This caused "Unknown syscall" errors when signal handlers returned via the trampoline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…b control setup Three fixes for BusyBox ash "can't access tty; job control turned off": 1. /dev/tty open now matches by session ID instead of PID. The controlling terminal belongs to the entire session, not just the session leader. When ash (child of bsh) opens /dev/tty, it needs to find the PTY that bsh (the session leader) set up via TIOCSCTTY. Previously matched by PID which failed for any non-session-leader process. 2. TIOCSCTTY now also sets foreground_pgid so tcgetpgrp() returns a valid value instead of 0. 3. bwm's spawn_child calls TIOCSCTTY after opening PTY slave, and libbreenix gains set_controlling_terminal() wrapper. Root cause confirmed by independent Codex + Opus investigation (panel of experts pattern). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code