From patchwork Wed Apr 15 21:04:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristen Carlson Accardi X-Patchwork-Id: 11492027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F71C81 for ; Wed, 15 Apr 2020 21:05:28 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 767BA2078B for ; Wed, 15 Apr 2020 21:05:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 767BA2078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-18504-patchwork-kernel-hardening=patchwork.kernel.org@lists.openwall.com Received: (qmail 13318 invoked by uid 550); 15 Apr 2020 21:05:20 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 12186 invoked from network); 15 Apr 2020 21:05:20 -0000 IronPort-SDR: 78rH0eZ/5zftqvJxtdCdpDWXVfKcz1C/6DuEH8t+ARTpe4VkCWnDg/QvAi1kiBeiPUPOtce7NL OwDhzbcZnxaQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False IronPort-SDR: wvo3hL9eNFcosc6V4uN+7Pt6fE3JfkOFJ2RXv84ZK2w4YDSzeRVy+Bowm7aQ4lFvhm6jlCKR2E hvAXA+ZLX16w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,388,1580803200"; d="scan'208";a="455035474" From: Kristen Carlson Accardi To: keescook@chromium.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, Josh Poimboeuf , Peter Zijlstra Cc: arjan@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, rick.p.edgecomb@intel.com Subject: [PATCH 1/9] objtool: do not assume order of parent/child functions Date: Wed, 15 Apr 2020 14:04:43 -0700 Message-Id: <20200415210452.27436-2-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415210452.27436-1-kristen@linux.intel.com> References: <20200415210452.27436-1-kristen@linux.intel.com> MIME-Version: 1.0 If a .cold function is examined prior to it's parent, the link to the parent/child function can be overwritten when the parent is examined. Only update pfunc and cfunc if they were previously nil to prevent this from happening. Signed-off-by: Kristen Carlson Accardi Acked-by: Josh Poimboeuf --- tools/objtool/elf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 09ddc8f1def3..2aa40f344392 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -408,7 +408,13 @@ static int read_symbols(struct elf *elf) size_t pnamelen; if (sym->type != STT_FUNC) continue; - sym->pfunc = sym->cfunc = sym; + + if (sym->pfunc == NULL) + sym->pfunc = sym; + + if (sym->cfunc == NULL) + sym->cfunc = sym; + coldstr = strstr(sym->name, ".cold"); if (!coldstr) continue;