From patchwork Mon Aug 30 18:22:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 12465775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C51C4320E for ; Mon, 30 Aug 2021 18:23:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE2D360FE6 for ; Mon, 30 Aug 2021 18:23:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EE2D360FE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 846C06B0074; Mon, 30 Aug 2021 14:23:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F60A6B0075; Mon, 30 Aug 2021 14:23:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BE558D0001; Mon, 30 Aug 2021 14:23:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 5C8BA6B0074 for ; Mon, 30 Aug 2021 14:23:12 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 107898249980 for ; Mon, 30 Aug 2021 18:23:12 +0000 (UTC) X-FDA: 78532569024.38.F491FA5 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf11.hostedemail.com (Postfix) with ESMTP id 343F4F0000AA for ; Mon, 30 Aug 2021 18:23:11 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10092"; a="282043641" X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="282043641" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2021 11:23:09 -0700 X-IronPort-AV: E=Sophos;i="5.84,364,1620716400"; d="scan'208";a="540650941" 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; 30 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 v30 00/10] Control-flow Enforcement: Indirect Branch Tracking Date: Mon, 30 Aug 2021 11:22:11 -0700 Message-Id: <20210830182221.3535-1-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Authentication-Results: imf11.hostedemail.com; dkim=none; spf=none (imf11.hostedemail.com: domain of yu-cheng.yu@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 343F4F0000AA X-Stat-Signature: xjxp9aynqyxe5bo8rxcmxqsgyhxuc9jg X-HE-Tag: 1630347791-997855 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Control-flow Enforcement (CET) is a new Intel processor feature that blocks return/jump-oriented programming attacks. Details are in "Intel 64 and IA-32 Architectures Software Developer's Manual" [1]. This is the second part of CET and enables Indirect Branch Tracking (IBT). It is built on top of the shadow stack series. Changes in v30: - Rebase to Linus tree v5.14. Changes in v29: - Rebase to Linus tree v5.14-rc6. Changes in v28: - Patch #10: Update change log and comments. - Rebase to Linus tree v5.14-rc2. Changes in v27: - Use a ucontext flag to save/restore IBT status. - Disable IBT support for IA32. - Rebase to Linus tree v5.13-rc2. [1] Intel 64 and IA-32 Architectures Software Developer's Manual: https://software.intel.com/en-us/download/intel-64-and-ia-32- architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4 H.J. Lu (3): x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking x86/vdso: Insert endbr32/endbr64 to vDSO x86/vdso/32: Add ENDBR to __kernel_vsyscall entry point Yu-cheng Yu (7): x86/cet/ibt: Add Kconfig option for Indirect Branch Tracking x86/cet/ibt: Add user-mode Indirect Branch Tracking support x86/cet/ibt: Handle signals for Indirect Branch Tracking x86/cet/ibt: Disable IBT for ia32 x86/cet/ibt: Update ELF header parsing for Indirect Branch Tracking x86/vdso: Introduce ENDBR macro x86/vdso: Add ENDBR to __vdso_sgx_enter_enclave arch/x86/Kconfig | 19 +++++ arch/x86/entry/vdso/Makefile | 4 + arch/x86/entry/vdso/vdso32/system_call.S | 2 + arch/x86/entry/vdso/vsgx.S | 4 + arch/x86/ia32/ia32_signal.c | 22 +++++- arch/x86/include/asm/cet.h | 13 ++++ arch/x86/include/asm/disabled-features.h | 8 +- arch/x86/include/asm/elf.h | 13 +++- arch/x86/include/asm/vdso.h | 20 ++++- arch/x86/include/uapi/asm/ucontext.h | 5 ++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/cet_prctl.c | 5 ++ arch/x86/kernel/ibt.c | 99 ++++++++++++++++++++++++ arch/x86/kernel/process_64.c | 6 ++ arch/x86/kernel/signal.c | 6 ++ 15 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 arch/x86/kernel/ibt.c