From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: debugedit@sourceware.org
Subject: [Bug debugedit/28408] debugedit segfaults while changing binutils' build-id
Date: Tue, 05 Oct 2021 11:04:58 +0000 [thread overview]
Message-ID: <bug-28408-13298-r11hXTFk2n@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28408-13298@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=28408
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-10-05
Status|UNCONFIRMED |ASSIGNED
CC| |mark at klomp dot org
Ever confirmed|0 |1
--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Thanks for the report and the reproducer.
Your analysis is correct.
The problem is summarized in this comment just before the problematic code:
/* Slurp the relevant header bits and section contents and feed them
into the hash function. The only bits we ignore are the offset
fields in ehdr and shdrs, since the semantically identical ELF file
could be written differently if it doesn't change the phdr layout.
We always use the GElf (i.e. Elf64) formats for the bits to hash
since it is convenient. It doesn't matter whether this is an Elf32
or Elf64 object, only that we are consistent in what bits feed the
hash so it comes out the same for the same file contents. */
So we mangled the actual data structure, but then check it as if it hasn't been
flipped around anyway when checking for NOBITS. The fix is to use the original
data/shdr to check for NOBITS:
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 668777a..3f1e830 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -3273,7 +3273,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
else
sha1_process_bytes (x.d_buf, x.d_size, &sha1_ctx);
- if (u.shdr.sh_type != SHT_NOBITS)
+ if (dso->shdr[i].sh_type != SHT_NOBITS)
{
Elf_Data *d = elf_getdata (dso->scn[i], NULL);
if (d == NULL)
--
You are receiving this mail because:
You are on the CC list for the bug.
next prev parent reply other threads:[~2021-10-05 11:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 16:33 [Bug debugedit/28408] New: " alexey.brodkin at gmail dot com
2021-10-05 11:04 ` mark at klomp dot org [this message]
2021-10-11 14:17 ` [Bug debugedit/28408] " 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-r11hXTFk2n@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).