From: "alexey.brodkin at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: debugedit@sourceware.org
Subject: [Bug debugedit/28408] New: debugedit segfaults while changing binutils' build-id
Date: Fri, 01 Oct 2021 16:33:30 +0000 [thread overview]
Message-ID: <bug-28408-13298@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=28408
Bug ID: 28408
Summary: debugedit segfaults while changing binutils' build-id
Product: debugedit
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: debugedit
Assignee: unassigned at sourceware dot org
Reporter: alexey.brodkin at gmail dot com
CC: debugedit at sourceware dot org
Target Milestone: ---
Created attachment 13694
--> https://sourceware.org/bugzilla/attachment.cgi?id=13694&action=edit
Cross-compiled m68k library
Initially seen on cross-compilation of Binutils in Debian and then
reported here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=995195.
In a nutshell "debugedit" segfaults on attempt to run the following command on
x86_64 host against a binary built for a big-endian architecture in this
example it's "libbfd-2.37-system.so" (attached) cross-compiled for m68k:
------------------------->8-----------------------
$ debugedit --build-id --build-id-seed=x libbfd-2.37-system.so
Segmentation fault
------------------------->8-----------------------
That's what we with GDB:
------------------------->8-----------------------
$ gdb --args ./debugedit --build-id --build-id-seed=x libbfd-2.37-system.so
(gdb) r
Starting program: .../debugedit/debugedit --build-id --build-id-seed=x
libbfd-2.37-system.so
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at
../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:365
365 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file
or directory.
(gdb) bt
#0 __memmove_avx_unaligned_erms () at
../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:365
#1 0x000055555555fea8 in memcpy (__len=83, __src=0x0, __dest=0x7fffffffe02d)
at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
#2 sha1_process_bytes (buffer=0x0, len=452, ctx=0x7fffffffdfe0) at
tools/sha1.c:210
#3 0x0000555555557d43 in handle_build_id (build_id_size=<optimized out>,
build_id_offset=16, build_id=0x555555566448, dso=0x5555555678d0) at
tools/debugedit.c:3285
#4 main (argc=<optimized out>, argv=<optimized out>) at tools/debugedit.c:3638
------------------------->8-----------------------
If we look a bit deeper we may notice that while processing ".bss" section
we're not seeing "u.shdr.sh_type == SHT_NOBITS" here
https://sourceware.org/git/?p=debugedit.git;a=blob;f=tools/debugedit.c;h=668777ad47d9b51d0cd118b7d91281963dafa6be;hb=HEAD#l3276.
Instead we see "u.shdr.sh_type = 0x08000000", which is exactly byte-swapped 0x8
which stands for SHT_NOBITS.
And since that check doesn't catch NOBITS section we later segfault trying to
process some other garbage.
That said there's something wrong with interpretation of a foreign endianess.
And this could be reproduced with both debugedit & elfutils built from today's
"master" barnches.
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2021-10-01 16:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 16:33 alexey.brodkin at gmail dot com [this message]
2021-10-05 11:04 ` [Bug debugedit/28408] " mark at klomp dot org
2021-10-11 14:17 ` mark at klomp dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-28408-13298@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=debugedit@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).