From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4999C433E1 for ; Thu, 21 May 2020 16:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DE04207F7 for ; Thu, 21 May 2020 16:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730123AbgEUQ5I (ORCPT ); Thu, 21 May 2020 12:57:08 -0400 Received: from mga02.intel.com ([134.134.136.20]:46206 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729787AbgEUQ5H (ORCPT ); Thu, 21 May 2020 12:57:07 -0400 IronPort-SDR: iuSrPnfKjh6/ckMYSrOidpjHYG4hPVAgkT1IIApjGe0Io0kda4yknWaGam86/dV5hub/jZ8sFM pTWnT+GFkAMg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 09:57:07 -0700 IronPort-SDR: aV3JFVvbrYZYbuv7t7Jyrk0/2sjsLErzP4zOHapmIGIX67EvDCFdYOJl51/67vJttU5gLr7E1I /Ec0D7WIPZhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,418,1583222400"; d="scan'208";a="309094669" Received: from kcaccard-mobl.amr.corp.intel.com (HELO kcaccard-mobl1.jf.intel.com) ([10.212.147.236]) by FMSMGA003.fm.intel.com with ESMTP; 21 May 2020 09:57:05 -0700 From: Kristen Carlson Accardi To: keescook@chromium.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, Josh Poimboeuf , Peter Zijlstra Cc: arjan@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, rick.p.edgecombe@intel.com, Kristen Carlson Accardi Subject: [PATCH v2 1/9] objtool: Do not assume order of parent/child functions Date: Thu, 21 May 2020 09:56:32 -0700 Message-Id: <20200521165641.15940-2-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200521165641.15940-1-kristen@linux.intel.com> References: <20200521165641.15940-1-kristen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 c4857fa3f1d1..b998c853a1f0 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; -- 2.20.1