Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1690711pxb; Fri, 20 Aug 2021 11:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw05p44ve5vF/e6YNrcgCKb+bb/DqSNTsAa3RxhD8WjUgFEHamezHPifJxj/fECbKnxlF/7 X-Received: by 2002:a6b:e90c:: with SMTP id u12mr15611669iof.95.1629483946818; Fri, 20 Aug 2021 11:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629483946; cv=none; d=google.com; s=arc-20160816; b=1AVEb9yUpQxG96uEISSshl2MHWq/F0d3hu5ozUYm2yVAWBXDCK4THgAFSQLZ/gG3ab gS0bmZHSFQVVnQHoK0TF+wi8eCVtx6lRGGtfff6urLX60U3MNI1IswOU9iJL5dXCx5Xg R6R/DvuNsq8HKRzzlurkMkcg+mEKpWHMHVw26yyodIkXmL1OTTSDO9EU+KH03MkRUj9S Jba9bNN/7aYedeJ5fa5YXgVdlTMOfTm6vN2YJHyjWGCQlJMMbLT9jGtnf+S4ou7cG9Cl G15Qel2vTLIbHCGquUEf750aOTk+VevPlS4J01wFeHRakR+lFAv+P4rRt5F4FhloTxHY iswQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W/hUD9i4F4U09mvGbK+xG5C7dtodYXib3zZoPX065a4=; b=fg4SPgc999wV8HthPcdMuaN75ZwC1uwbh5MeCZqGvRA1Q6SRLbgTxUGUgUHOtntJny L2twvaGGrvlWE92tNvyObCf3204wEc4RlzTHotK3D+RIxWyjfBbOykW4zyMXMIJImBGk QDJKF8Y9DCQiUw4U+NhftwqfYiWeaJ/y2c7wktI5tQachwkcGBV9iMpNx/Qqh4PZx88s +wVgvRqZ3UKm1dt3grVwU1hmBo2MtEXQiShV/zQGCJRFhi4OVfa8j7oNHaY9GKEbxhfB pcwJWneEyy0AruByk2DZO2GQovu9hu5/ptHd3QAKv5aMQOLDG4maBaY4YYwk2A5wUhpw 3JsA== 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 e101si7345318jai.50.2021.08.20.11.25.34; Fri, 20 Aug 2021 11:25:46 -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 S238228AbhHTSYb (ORCPT + 99 others); Fri, 20 Aug 2021 14:24:31 -0400 Received: from mga18.intel.com ([134.134.136.126]:48116 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238733AbhHTSYS (ORCPT ); Fri, 20 Aug 2021 14:24:18 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="203964951" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="203964951" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 11:23:08 -0700 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="523799165" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 11:23:08 -0700 From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , Rick P Edgecombe Cc: Yu-cheng Yu Subject: [PATCH v29 05/10] x86/cet/ibt: Update ELF header parsing for Indirect Branch Tracking Date: Fri, 20 Aug 2021 11:22:40 -0700 Message-Id: <20210820182245.1188-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210820182245.1188-1-yu-cheng.yu@intel.com> References: <20210820182245.1188-1-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An ELF file's .note.gnu.property indicates features the file supports. The property is parsed at loading time and passed to arch_setup_elf_ property(). Update it for Indirect Branch Tracking. Signed-off-by: Yu-cheng Yu Cc: Kees Cook --- v27: - Remove selecting of ARCH_USE_GNU_PROPERTY and ARCH_BINFMT_ELF_STATE, since they are already selected by X86_64. --- arch/x86/kernel/process_64.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 4271963fdd8c..4ab751a5146e 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -884,6 +884,12 @@ int arch_setup_elf_property(struct arch_elf_state *state) if (state->gnu_property & GNU_PROPERTY_X86_FEATURE_1_SHSTK) r = shstk_setup(); + + if (r < 0) + return r; + + if (state->gnu_property & GNU_PROPERTY_X86_FEATURE_1_IBT) + r = ibt_setup(); #endif return r; -- 2.21.0