Skip to content

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

Merged
Yhg1s merged 2 commits into
python:3.12from
stratakis:3.12_branch_protections
Aug 4, 2026
Merged

Yhg1s merged 2 commits into
python:3.12from
stratakis:3.12_branch_protections

Conversation

@stratakis

@stratakis stratakis commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

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

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. It's a backport of a fix already merged in stable branches.

@Yhg1s
Yhg1s merged commit d9d98e0 into python:3.12 Aug 4, 2026
27 checks passed
@stratakis
stratakis deleted the 3.12_branch_protections branch August 6, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants