Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4833562pxy; Tue, 27 Apr 2021 13:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdcGIB+47MoDzOpk8AfFqk+oZlTBl3NOeOOkIuYzNGRqoquw/8t3+kBsdS6HGmkuDxDYFj X-Received: by 2002:aa7:c349:: with SMTP id j9mr6571994edr.230.1619556574651; Tue, 27 Apr 2021 13:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619556574; cv=none; d=google.com; s=arc-20160816; b=t7DYg/El+ruTgEM3maIVSOz/U2/PI9Kq4h3y/OsL+AXm8WWLI0u+SgjsPKeCldt6e5 PY6LMD8hwdXjTYJeyeG8Nf/m0iqIt7qIapGKQ9lhHo6jRExZR5+sJVKrZ6ytpgfouxM/ WXs8GKPTk9hOYImfJoXvbXVLv3KU3KBHRtgbNYsQVZEx7I82mzH3uXsYkyjRP5dpfk7x vYSBb21G5jorwQ7sul59wvF/zo2pl/U/qriMxzztDCLp/E5bV7gOaBCco0YlXliz+/lZ +BD4cSSH15AY1jPcai0eGHsgma9YsqgU42/6laav98hX4EwzF6scZJlChpICMd21VkQa Cchg== 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 :ironport-sdr:ironport-sdr; bh=JkMBaKtI8NUeW/SG8mDX809W9F699JXkwJxgTlnYWd0=; b=OvaQBk5BWRAGWIdSlngqJYYbSCpFZn3NmhjdNMUO3mKLm+bOX2+v5isJvxFt6u4tQs 3TLSvM3iPXyS94oAWdhTH3WFxFkLrDC7JEU5HopVbnGxxl9q21f1CeF/OlHl0x1wIGtv o8Pxu1PEeufXdXnsJvEXF4Z3ffuGuS75ke8fYyStko+4GaKZiak3V66ISyGYt8Dw874W fp8k3j7VGHT0tnuxqJsTSWswhfh21lc0lPKNSjvXSsqU4AVsRTSqLjZL+VH5XEUba3ql HaIScwiGogeCMOZDI+5bVCca1ntU/GedaNB20BsyAnnq60l6RxrrzWWIVzljWaEr/w/0 1ZZg== 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 o10si829179ejd.653.2021.04.27.13.49.09; Tue, 27 Apr 2021 13:49:34 -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 S239173AbhD0Usz (ORCPT + 99 others); Tue, 27 Apr 2021 16:48:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:56328 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239021AbhD0Usl (ORCPT ); Tue, 27 Apr 2021 16:48:41 -0400 IronPort-SDR: y379xGZErhfRKSPo7GaDK6AiELiu2U1+wcKIXVLDfkm4us68/+zQV7XZqFMLs8cjWBBTmiEDHI F3V7D0h8oNVA== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="196699388" X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="196699388" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47:47 -0700 IronPort-SDR: iogEKj49eNEn3Jj98ysuiJ5T4AT3mLkPcsCQgfuMLmQNMskffVqisSeGgc3tRZuyOjt154vPhf 3YGKuAScx6dg== X-IronPort-AV: E=Sophos;i="5.82,255,1613462400"; d="scan'208";a="457835083" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 13:47:47 -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" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Cc: Yu-cheng Yu Subject: [PATCH v26 4/9] x86/cet/ibt: Update ELF header parsing for Indirect Branch Tracking Date: Tue, 27 Apr 2021 13:47:15 -0700 Message-Id: <20210427204720.25007-5-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210427204720.25007-1-yu-cheng.yu@intel.com> References: <20210427204720.25007-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 --- v24: - Update for changes introduced from splitting shadow stack and ibt. arch/x86/Kconfig | 2 ++ arch/x86/kernel/process_64.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 6bb69fba0dad..7436e3a608e8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1970,6 +1970,8 @@ config X86_IBT def_bool n depends on X86_SHADOW_STACK depends on $(cc-option,-fcf-protection) + select ARCH_USE_GNU_PROPERTY + select ARCH_BINFMT_ELF_STATE help Indirect Branch Tracking (IBT) provides protection against CALL-/JMP-oriented programming attacks. It is active when diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index d71045b29475..bf8ef10e5b78 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -864,6 +864,14 @@ int arch_setup_elf_property(struct arch_elf_state *state) r = shstk_setup(); } + if (r < 0) + return r; + + if (cpu_feature_enabled(X86_FEATURE_IBT)) { + if (state->gnu_property & GNU_PROPERTY_X86_FEATURE_1_IBT) + r = ibt_setup(); + } + return r; } #endif -- 2.21.0