Skip to content

x86: fault: emulate trampolines that start with endbr - #87

Merged
kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-207-openpax-endbr-trampolines
Nov 5, 2026
Merged

kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-207-openpax-endbr-trampolines

Conversation

@kdaula

@kdaula kdaula commented Nov 5, 2026

Copy link
Copy Markdown

OpenPaX EMUTRAMP kills any program that calls a gcc nested function through its stack trampoline when gcc built it with -fcf-protection, the default on Ubuntu and Fedora. gcc then starts the trampoline with endbr64, and openpax_emulate_trampoline_64() compares the bytes at the faulting address against patterns that start with a mov, so nothing matches and the task gets SIGSEGV.

Both matchers now skip a leading endbr64 or endbr32 before comparing. The 32-bit relative jump target is computed from the address after it.

Tested on edera/6.18-lts in a Xen PV zone, where a CET-built nested-function trampoline went from SIGSEGV to running. The 32-bit path was not exercised.

COR-207

gcc built with -fcf-protection, the default on Ubuntu and Fedora,
starts its nested-function trampolines with endbr64, or endbr32 for
32-bit code. The EMUTRAMP matchers compare the bytes at the faulting
address against trampolines that start with a mov, so none of these
match and the task is killed with SIGSEGV.

Skip a leading endbr before matching. The only relative target, the
32-bit jmp, is computed from the address after it.

Signed-off-by: Kavi <kavi@edera.dev>
Comment thread arch/x86/mm/fault.c
int err;

/* With -fcf-protection, gcc starts its trampolines with endbr32. */
if (!get_user(endbr, (unsigned int __user *) ip) && endbr == 0xFB1E0FF3)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't like magic numbers

@kdaula
kdaula merged commit ec5588a into edera/mainline Nov 5, 2026
3 checks passed
@kdaula
kdaula deleted the kavi/cor-207-openpax-endbr-trampolines branch November 5, 2026 16:19
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Backport to edera/6.18-lts: proposed in #91

Checks and builds passed.

Run log

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