From: Artem Savkov <asavkov@redhat.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, Artem Savkov <asavkov@redhat.com>
Subject: [PATCH v3 1/2] objtool: fix failed cold symbol doublefree
Date: Mon, 12 Nov 2018 13:55:18 +0100 [thread overview]
Message-ID: <20181112125519.26855-2-asavkov@redhat.com> (raw)
In-Reply-To: <20181112125519.26855-1-asavkov@redhat.com>
If read_symbols() fails during second list traversal (the one dealing
with ".cold" subfunctions) it frees the symbol, but never deletes it
from the list/hash_table resulting in symbol being freed again in
elf_close().
Fixes: 13810435b9a7 "objtool: Support GCC 8's cold subfunctions"
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
tools/objtool/elf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6dbb9fae0f9d..3decd43477df 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -312,7 +312,7 @@ static int read_symbols(struct elf *elf)
if (!pfunc) {
WARN("%s(): can't find parent function",
sym->name);
- goto err;
+ goto cold_err;
}
sym->pfunc = pfunc;
@@ -336,6 +336,9 @@ static int read_symbols(struct elf *elf)
return 0;
+cold_err:
+ list_del(&sym->list);
+ hash_del(&sym->hash);
err:
free(sym);
return -1;
--
2.17.2
next prev parent reply other threads:[~2018-11-12 12:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 14:05 [PATCH] objtool: fix .cold. functions parent symbols search Artem Savkov
2018-11-07 17:08 ` Josh Poimboeuf
2018-11-07 18:42 ` Artem Savkov
2018-11-07 20:29 ` Josh Poimboeuf
2018-11-07 21:45 ` [PATCH v2] " Artem Savkov
2018-11-09 17:23 ` Josh Poimboeuf
2018-11-10 12:18 ` Artem Savkov
2018-11-12 3:38 ` Josh Poimboeuf
2018-11-12 12:55 ` [PATCH v3 0/2] objtool: read_symbols() fixes Artem Savkov
2018-11-12 12:55 ` Artem Savkov [this message]
2018-11-19 17:57 ` [PATCH v3 1/2] objtool: fix failed cold symbol doublefree Josh Poimboeuf
2018-11-12 12:55 ` [PATCH v3 2/2] objtool: fix .cold functions parent symbols search Artem Savkov
2018-11-19 18:02 ` Josh Poimboeuf
2018-11-20 8:05 ` [PATCH v4 0/2] objtool: read_symbols() fixes Artem Savkov
2018-11-20 8:05 ` [PATCH v4 1/2] objtool: fix failed cold symbol doublefree Artem Savkov
2018-11-20 8:05 ` [PATCH v4 2/2] objtool: fix .cold functions parent symbols search Artem Savkov
2018-11-20 14:12 ` [PATCH v4 0/2] objtool: read_symbols() fixes Josh Poimboeuf
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=20181112125519.26855-2-asavkov@redhat.com \
--to=asavkov@redhat.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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 NNTP newsgroup(s).