Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2532214pxa; Mon, 24 Aug 2020 17:35:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeJtHe7+mm2RMPyJouW+0XFAQ/uWUys4sBQ/egIYFEfVbWreaC+zOAG5VK+CziIBH3PGZg X-Received: by 2002:a50:be82:: with SMTP id b2mr7929318edk.303.1598315749805; Mon, 24 Aug 2020 17:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598315749; cv=none; d=google.com; s=arc-20160816; b=wSZAJdBOIxkSsd+EOBZNQre5ioVfTGUK16qz9fS7PkXrBwjrEAKyHX7lHa9YMiAhPr L6FyK92Ug/XBVJW/mqDjt8tJU9l/6p6+Tx976+6WvCco1GKLUB0H51BXzUUHBEt3Ya/g AT4h0nbBMRr4KWuqRCm6k6I9n281Jj+wsgZ/SJW8G0BDmh98CALXt+v6qpqkLWjUWGFX LH3Wy/a6Kq+GUBX8PIV93Q037fbjjEHnQQGHWpCwyajgeRt2SFx/De1Tjo5N7JNJ9/nL 2aYxp68RpsR1/nz0v/WYF0bs0kpp4A5BfHbvfC9Z0NwbNHr5oAtqj2bkzcxRQ8rKWNHg lhKw== 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=pd8vphqePbqpQ3SUa8OYcaut1H6kKB+R5QE0mjWy5iQ=; b=FxsSy3d2UFO5L3nemi+7dDOTfsDNZSWc81ZnqDyTw6dgoRGagZ0VYeBgZHG+TKA6dZ 9Yq9jrVZGvhqmJQbae2463zZZKEuoQpjOp5MrIcRtRZ+CbuVND/j+1AXRa2FTSFqLssV Rvl5iyCXTcqcQTm3C08Uw9bhzKwxiWEzlF9T5Lf0YWNj339a8fODgoDQdzjottQ4r6xy sw2IemEZlQzI9iVEtx6m4ZFEkk3PloY36BOJ3OIgWEkNgC9rGsE9fgMuxV4hnGFEpP+z OnliQDzqIkHQo5TrtdEkIMga3rYrIAHydc7ZLrMW7eOOd6b6mol/3kFdUrHKLogcOQIS qYwA== 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 yj16si8686245ejb.59.2020.08.24.17.35.27; Mon, 24 Aug 2020 17:35:49 -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 S1728661AbgHYAcC (ORCPT + 99 others); Mon, 24 Aug 2020 20:32:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:28750 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728257AbgHYAai (ORCPT ); Mon, 24 Aug 2020 20:30:38 -0400 IronPort-SDR: AKZ8ntHbhUz1e7FR7xrx7uz8VaouiMgN9//EtyrGAbMd1tjtklsXIXXYSppUCez/5BHdasuVE/ 5W72Uak3M1wQ== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="174053266" X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="174053266" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:30:35 -0700 IronPort-SDR: EGKN8o+mtfUJhweX7e6D9P4+AGQ8EmhSBD0hf/vqqKtFCv6xXHw0qBj/+CF28xLNEHbB6spIYc nixR9RRRRfmw== X-IronPort-AV: E=Sophos;i="5.76,350,1592895600"; d="scan'208";a="443429314" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2020 17:30:35 -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 Cc: Yu-cheng Yu Subject: [PATCH v11 4/9] x86/cet/ibt: ELF header parsing for Indirect Branch Tracking Date: Mon, 24 Aug 2020 17:26:39 -0700 Message-Id: <20200825002645.3658-5-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200825002645.3658-1-yu-cheng.yu@intel.com> References: <20200825002645.3658-1-yu-cheng.yu@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 Update arch_setup_elf_property() for Indirect Branch Tracking. Signed-off-by: Yu-cheng Yu --- v9: - Change cpu_feature_enabled() to static_cpu_has(). 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 b047e0a8d1c2..5bd6d6a10047 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1969,6 +1969,8 @@ config X86_INTEL_BRANCH_TRACKING_USER depends on CPU_SUP_INTEL && X86_64 depends on $(cc-option,-fcf-protection) select X86_INTEL_CET + 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 fd4644865a3b..c084e1a37d11 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -866,6 +866,14 @@ int arch_setup_elf_property(struct arch_elf_state *state) r = cet_setup_shstk(); } + if (r < 0) + return r; + + if (static_cpu_has(X86_FEATURE_IBT)) { + if (state->gnu_property & GNU_PROPERTY_X86_FEATURE_1_IBT) + r = cet_setup_ibt(); + } + return r; } #endif -- 2.21.0