Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2134942ybh; Fri, 17 Jul 2020 10:04:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys0UOP9mQmX32RM3VbIDdw3kMGic9/TVnwsNwZLr2ZlsdI4r04GDjIvSTTmcxwwccVaH1q X-Received: by 2002:a17:906:3ac4:: with SMTP id z4mr8879161ejd.65.1595005482147; Fri, 17 Jul 2020 10:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595005482; cv=none; d=google.com; s=arc-20160816; b=n/PeAjJQMbPWvJYerAPqASpEPaYZ5zL7jLwRXeW6kZmog7belBfcmO1gJzCvHU4SAy D/p3Fqj98X/Upg/NsUE2MxEt2ooCnbj5QWvJCFRWO0cUKLaepW3L9GyL0X5A/BypkLxP /Vc+7fpbANr9E5sgPTXGYNzOe/TAwbuh2NE8r4OvSzlhsUXluBbOMCArTZ3o44D/N5QP BF6qtq5wBuh94xY9qa2aLbj/Sc76XWCuuHuhaLBu9DrczzMY+iX68zxV4Rpokd/H1yuT XkU7/qXD/ayIORMC/rBYUvT33bma1ashGt68JcRgGfsz+D4zcPKPHwYLLyRAUxYHBu4J bsmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=ktA2mWNcHt/wE1D8Nq2Ud27X6V8hRSaWoa7aqHW85Js=; b=E9ytInOLrzkIB/DuR8RngppaEjz5pLynMASqqPf0z293oHeurwWf40EIy/YvmjFNLU b7wkuhJFFILPY4SuCmW0+pgzeXH9ZVl2YV2n1HA+fc3fXG3/u/tQBrSKIBj6I1by8O3i tkm3KeJqP9mCeNDXmg5YBoiz133Sool5TRhzdZnd+7VzWQY+zMkckUj7c5VzjK9F/Ue1 ed3VCNR8C6c63orn7qoFk2/PpJVSm6J130OQ4IL9r0wdDmil3kgcYTkjiMFug9Y8Khel 1iH4rJ5eEK9qyw3xzn2NDhyKGYTciYwoCpABxfGukSh7G/NjIbxb5iOem039oiT6Q5WS OCaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si5379390ejj.363.2020.07.17.10.04.18; Fri, 17 Jul 2020 10:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728121AbgGQRAz (ORCPT + 99 others); Fri, 17 Jul 2020 13:00:55 -0400 Received: from mga14.intel.com ([192.55.52.115]:45269 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbgGQRAa (ORCPT ); Fri, 17 Jul 2020 13:00:30 -0400 IronPort-SDR: vk6RT8B8QoEsYPs1pJMLvz6Ne19FEsqLhkPzjr88Cb08N3l2WIy5Gn4QouD/6qVnewNF3vy9v7 NobeiVFU2ilg== X-IronPort-AV: E=McAfee;i="6000,8403,9685"; a="148798229" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="148798229" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 10:00:28 -0700 IronPort-SDR: YD8LS8cLsoXNAWwVei30GXmcCE2h7XpytjuYYlCGZNftLJ3LEHvqt3ks4PtvSBIw+y6vWNjsRH TSCZNWQa1wAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="270861825" Received: from kcaccard-mobl.amr.corp.intel.com (HELO kcaccard-mobl1.jf.intel.com) ([10.212.33.149]) by fmsmga008.fm.intel.com with ESMTP; 17 Jul 2020 10:00:22 -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 v4 01/10] objtool: Do not assume order of parent/child functions Date: Fri, 17 Jul 2020 09:59:58 -0700 Message-Id: <20200717170008.5949-2-kristen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200717170008.5949-1-kristen@linux.intel.com> References: <20200717170008.5949-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 26d11d821941..c18f0f216740 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -434,7 +434,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