-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRASH loading private glibc 2.39-4 from relocation error #7120
Comments
derekbruening
added a commit
that referenced
this issue
Dec 10, 2024
Despite "rela" relocations having an explicit addend value and it being set to non-0 in a new Debian glibc, the addend is assumed to *not* be added to the symbol value when relocating on x86_64 and aarch64 (it does seem to be added on RISCV). This is not obvious and not well documented; we have to just behave like existing loaders behave from experimentation/examination. (Yet another reason to possibly invert the private loader and let the private copy of ld.so do all the loading and relocating: #5437). Tested on a machine where nearly every client test in our suite was crashing after a glibc update: now they pass. Unfortunately it's not simple to make automated tests for this: we don't have an existing framework for relocation testing and it would take non-trivial effort to construct that, beyond the scope of this fix. Fixes #7120
Merged
derekbruening
added a commit
that referenced
this issue
Dec 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After a machine update, every client that uses lbc crashes up front during loading:
This is the libc version:
I thought we had already gotten 2.39 to work wrt #5437: and that part does seem to be correct here.
The crash is just a few instructions later when
__libc_early_init
calls__pthread_tunables_init
and it tries to call__tunable_get_val
in ld.so through the PLT:Without DR:
Isn't [email protected] just a regular import?
We find it:
Our code:
More diagnostics:
So it's the addend for being "rela": if the addend were 0 it would have
done the right thing.
They all have non-0 addends -- why?
From above, 0x28330 is listed in the symbol but how to interpret?
Looks like tunable_get_val plus 0x28330 not that it's at the PLT slot
0x28330 yet the address ending in 330 can't be a coincidence.
In glibc's elf_machine_rela() for x86_64: it
adds r_addend to other types, but not to R_X86_64_JUMP_SLOT or
R_X86_64_GLOB_DAT. So why have those use rela entries? Does some other
code need the PLT offset and they hackily store that in r_addend?
For aarch64: r_addend is added for GLOB_DAT and JUMP_SLOT.
For riscv: r_addend is not added for JUMP_SLOT.
No r_addend reference for 32-bit arm or x86.
The text was updated successfully, but these errors were encountered: