[Bug libelf/28685] UBSan: member access within misaligned address 0x7ff316818032 for type 'struct Elf32_Phdr'

mark at klomp dot org sourceware-bugzilla@sourceware.org
Sun Dec 19 23:57:14 GMT 2021


--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Evgeny Vereshchagin from comment #2)
> If callers are
> expected to pass correctly aligned buffers it seems
> dwfl_segment_report_module should be fixed. But it seems that callers can
> sometimes assume that it should be fine to pass unaligned data. For example,
> (even though it has nothing to do with the xlateto functions) in one of
> libbpf issues it was pointed out that "I don't see anywhere the requirement
> that bytes passed to the elf_memory() should be aligned, so this does seem
> like libelf bug."

I am not sure I like people explicitly passing in unaligned buffers to
elf_memory (). We'll need to carefully audit that works. It also means lots of
copying data structures around to get a correctly aligned version. Also the
xlate functions work on Elf_Data, I think it is reasonable to assume those
normally come from other libelf functions and that the d_buf pointers are
correctly aligned for the d_type.

For now I just fixed up the code in dwfl_segment_report_module to make sure the
buffers passed to the xlate functions are properly aligned. See the following
proposed patches:


You are receiving this mail because:
You are on the CC list for the bug.

More information about the Elfutils-devel mailing list