Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1572679ybk; Thu, 21 May 2020 09:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+1fyehycexg2wJbfcZrxvSNPrEOK5iu4OtYU7gTHnZkwg8OYYwHgMNn8ck5YTOIPdhHIg X-Received: by 2002:a17:906:2c03:: with SMTP id e3mr4360038ejh.206.1590080369853; Thu, 21 May 2020 09:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590080369; cv=none; d=google.com; s=arc-20160816; b=ehQdyLBK4O6nKYrhUbYGnnJWNbXbf8PddUZCWBBQJFz7TAcRESnt2IoVMOT3LyriQ/ jHH8uZmU7P++p/cMlMwsRQ0Wfd2CWjSj9+MY1sbgFU9OCaxWfBnyNm19ODOWcLZzizrx M7NakthbNKxfYIK08WpfG2gDF7sdSAfyGo2UIBDsyECU/YtcL1xDQgmwTO1gTU+s80fj tB1P0PlUhdpbxtakGN5c+Sr8R7HA1nKiRhBPRB/fyZJrWyJXWIKR48sQ07hY0+qS0j/0 Zs/fz1RG6M6VyeP9h63iT9ckvY326/YVPTs8C+xUDTUoAWTjiiQVCRJBsLTf8xwI+Z9h M+6A== 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=nRNpyr+eLlVCXVHlG41vV7QyqI6rLgLXQrSwoGyEx0w=; b=D0q5gre2HfPhBc32GDSu/CN3MNaiLzmt/jlpclh+QyCq7VvujvWhDLkThTkNlBir9d qpf4tAwC3evOs32gphsuF/ePCSSnaOQ+bdBS5GkF/CVdAGeSUjVuXwTqbrE9xbWmpwB2 1IHulRoPNxJVDBE1LQicRc2MBVU0T4S2ngUVNdcjLQ/UOvoXwh8AtCLdehxvSFE1uCUw AQsSGVn2NgD9guHtM4dRzinGpeisrNbnbNc1w/bBU0JiIZW/4PvqmJCSXX4+5zgF/UxJ B1BncOZyQKl9zAm/K5hazGkhtM/OoRug2n7wiyn7833GKUD4eQ28O6UEpLwQAMz7MFbJ 2bRw== 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 z8si3775704ejf.525.2020.05.21.09.59.06; Thu, 21 May 2020 09:59:29 -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 S1730119AbgEUQ5I (ORCPT + 99 others); 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