Skip to content

[3.12] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (#130864)#150198

Open
stratakis wants to merge 1 commit into
python:3.12from
stratakis:3.12_branch_protections
Open

[3.12] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (#130864)#150198
stratakis wants to merge 1 commit into
python:3.12from
stratakis:3.12_branch_protections

Conversation

@stratakis
Copy link
Copy Markdown
Contributor

@stratakis stratakis commented May 21, 2026

Apply protection against ROP/JOP attacks for aarch64 on asm_trampoline.S.

The BTI flag must be applied in assembler sources for this class of attacks to be mitigated on newer aarch64 processors.

See also:
https://sourceware.org/annobin/annobin.html/Test-branch-protection.html and
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64

…mpoline.S (python#130864)

Apply protection against ROP/JOP attacks for aarch64 on asm_trampoline.S.

The BTI flag must be applied in assembler sources for this class
of attacks to be mitigated on newer aarch64 processors.

See also:
https://sourceware.org/annobin/annobin.html/Test-branch-protection.html
and
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64

Co-authored-by: Victor Stinner <vstinner@python.org>
@stratakis
Copy link
Copy Markdown
Contributor Author

3.12 is currently on security only fixes.

This issue resolves a security issue when compiling on aarch64 with -mbranch-protection. Without the PR, when using -mbranch-protection=standard to enable the aarch64 hardware protections, the linker will see that there is a missing note from the object files generated by the assembly sources and will drop the notes from the final binary/library, deactivating the protections.

Verified that perf integration works well, with and without the flag, including frame pointers. And the final binary correctly shows BTI, PAC, GCS with readelf -n.

cc @vstinner @Yhg1s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant