-
Notifications
You must be signed in to change notification settings - Fork 217
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
libbacktrace: fix unaligned read of the header of the compressed debug section #120
libbacktrace: fix unaligned read of the header of the compressed debug section #120
Conversation
Have you seen a real program with a misaligned |
I'm using LD LLD linker from the LLVM project.
Yes, it was a real program for which I recently started using the
readelf --sections looks like for a simple program |
Thanks. That looks like a bug in lld. It should be setting I guess we should work around the bug, though. |
Patch originally by GitHub user ubyte at #120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Thanks, I committed the patch upstream and merged it back into this repo. |
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Thank you! |
On ELF64, it looks like BFD uses 8-byte alignment for compressed The specification's wording makes me confused whether it really requires 8-byte alignment, even if a non-packed
There are many |
The compressed section starts with a struct that requires 8-byte alignment on a 64-bit system, so it seems to me that the compressed section should have 8-byte alignment. That's how every other ELF structure works, after all. If this is an exception, then the standard should explicitly call it out as such. What it does say is that |
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
Patch originally by GitHub user ubyte at ianlancetaylor/libbacktrace#120. * elf.c (elf_uncompress_chdr): Don't assume compressed section is aligned.
The type
b_elf_chd
requires 8 byte alignment on a 64-bit platform, but a compressed debug section may be stored with less restrictive alignment.That misalignment read may cause program termination if it was compiled with the UndefinedBehaviorSanitizer enabled.