From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 61A263858400; Sun, 19 Dec 2021 23:57:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61A263858400 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libelf/28685] UBSan: member access within misaligned address 0x7ff316818032 for type 'struct Elf32_Phdr' Date: Sun, 19 Dec 2021 23:57:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libelf X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mark at klomp dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Dec 2021 23:57:14 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28685 --- Comment #3 from Mark Wielaard --- (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 examp= le, > (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 requireme= nt > 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 followi= ng proposed patches: https://sourceware.org/pipermail/elfutils-devel/2021q4/004552.html https://sourceware.org/pipermail/elfutils-devel/2021q4/004561.html https://sourceware.org/pipermail/elfutils-devel/2021q4/004562.html --=20 You are receiving this mail because: You are on the CC list for the bug.=