Skip to content

Align pushed argv table before execve on AArch64#346

Open
Ebola-Chan-bot wants to merge 1 commit intotermux:masterfrom
Ebola-Chan-bot:termux-upstream/fix-aarch64-execve-argv-alignment
Open

Align pushed argv table before execve on AArch64#346
Ebola-Chan-bot wants to merge 1 commit intotermux:masterfrom
Ebola-Chan-bot:termux-upstream/fix-aarch64-execve-argv-alignment

Conversation

@Ebola-Chan-bot
Copy link
Copy Markdown

When shebang expansion rewrites argv[] through push_array_of_xpointers(), the copied pointer table can land at a misaligned stack address on AArch64. The kernel then rejects execve() with EFAULT even though argv, envp and the strings remain readable.

Compute padding from the current stack pointer before alloc_mem() so the copied block stays 16-byte aligned on AArch64 and word aligned on other architectures. The padding stays above the copied block, so the previously computed pointee offsets remain valid.

When shebang expansion rewrites argv[] through push_array_of_xpointers(),
the copied pointer table can land at a misaligned stack address on AArch64.
The kernel then rejects execve() with EFAULT even though argv, envp and the
strings remain readable.

Compute padding from the current stack pointer before alloc_mem() so the
copied block stays 16-byte aligned on AArch64 and word aligned on other
architectures. The padding stays above the copied block, so the previously
computed pointee offsets remain valid.
Copilot AI review requested due to automatic review settings April 14, 2026 14:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an AArch64-specific execve() failure where shebang expansion rewrites argv[] via push_array_of_xpointers() and the newly pushed argv pointer table can end up misaligned on the tracee stack, causing the kernel to reject execve() with EFAULT.

Changes:

  • Compute stack padding before alloc_mem() so the pushed pointer table base remains 16-byte aligned on AArch64.
  • Preserve existing behavior on other architectures by aligning to the tracee word size.
  • Keep padding above the copied data to avoid invalidating previously computed pointee offsets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/execve/aoxp.c
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