Skip to content

Fix libRemoteInput-x86_64.so failing to load on glibc 2.41+ (executable stack) - #10

Open
thefriendlyhedgehog wants to merge 1 commit into
Brandon-T:masterfrom
thefriendlyhedgehog:fix-linux-noexecstack
Open

thefriendlyhedgehog wants to merge 1 commit into
Brandon-T:masterfrom
thefriendlyhedgehog:fix-linux-noexecstack

Conversation

@thefriendlyhedgehog

Copy link
Copy Markdown

On current Linux distros (glibc 2.41+) the x86_64 Linux build can't be loaded. Simba shows:

Loading plugin failed. Architecture mismatch? (expected a 64 bit plugin)

The real error from dlopen is:

cannot enable executable stack as shared object requires

The shipped libRemoteInput-x86_64.so has PT_GNU_STACK marked RWE. The aarch64 build is RW:

$ readelf -lW libremoteinput64.so | grep GNU_STACK
  GNU_STACK  0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10

The cause is RemoteInput/Thirdparty/kubo_injector/src/linux/shellcode.S. It has no .note.GNU-stack section, so the linker marks the whole library as needing an executable stack. glibc 2.41 stopped allowing that in dlopen.

This PR adds the standard note (guarded with __ELF__). The shellcode gets injected into the target process and never runs from the stack, so the note doesn't change behaviour.

Tested: the object built from the patched file now carries the note. Clearing the flag on the shipped .so makes it load in Simba again, and pairing works.

shellcode.S has no .note.GNU-stack section. Linkers that default to an
executable stack for unmarked objects (as the x86_64 Linux CI build does)
therefore mark the whole libRemoteInput-x86_64.so PT_GNU_STACK RWE.

Since glibc 2.41, dlopen refuses to load a library that requests an
executable stack: "cannot enable executable stack as shared object requires".
Simba reports this as "Loading plugin failed. Architecture mismatch?", so the
plugin cannot be loaded at all on current distros.

The shellcode is injected into the target process, never executed on the
stack, so the note is safe. Guarded with __ELF__ so non-ELF assemblers are
unaffected.
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.

1 participant