From patchwork Mon Feb 27 22:29:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgecombe, Rick P" X-Patchwork-Id: 13154267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4431C7EE31 for ; Mon, 27 Feb 2023 22:32:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81FA86B00A8; Mon, 27 Feb 2023 17:32:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F6B36B00A9; Mon, 27 Feb 2023 17:32:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 648CE6B00AA; Mon, 27 Feb 2023 17:32:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 43FA16B00A9 for ; Mon, 27 Feb 2023 17:32:01 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1FC0BC0A5F for ; Mon, 27 Feb 2023 22:32:01 +0000 (UTC) X-FDA: 80514520842.03.342E7D0 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf28.hostedemail.com (Postfix) with ESMTP id 337E4C0010 for ; Mon, 27 Feb 2023 22:31:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=QJ9mpQfh; spf=pass (imf28.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677537119; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=LY7sRJ+HhyH/fRQUu6yhwRH2pCUOOjl5GAOCVlgILp0=; b=p/cJ/nQrxMI9h3kE7ktmohA7+7ytQ3Ch5tIfwzfQF8NdytKdekTu/1vwk7ZHaTPIeqkBfV zIXl5hCEi5tHJ4KbfEKVTeSkfl9sUQhKKrK2f2tGE8GzafDiOM1wjhUgRElu19HKpzH/tk wSQXDfvrN4EgZU5bBUuCGhSpmL1Xfbw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=QJ9mpQfh; spf=pass (imf28.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677537119; a=rsa-sha256; cv=none; b=qbMAel2XTtR4EaJO59zhvxQzXFldBcErm89iJyMWPYtU4n08eo7PAKjIgkl+9sWXEa5Qlz hMdsvcCiPXg94YpeRiMeOtQETQi8cnTWJiIjklzwW+59IzdTaT5UgggsKJAkisPoPrF2Pw okf712YZo/txgw9+dP5RAqEJBx79Lbs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677537119; x=1709073119; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=u0fpzllgXo4dayZIZ+QVsU1muHhaSbmjAoWT0A5Xxuo=; b=QJ9mpQfheFI0ujQgeItINSK9vwxvSBQzUT5EaRhZy24DQtG+7PbqwPpd fISUdOcxUvovqryKxXKn1zXIDdt4CY33Yn9ZkR/1Szj+FUaxP6zzUiPdo SYNpD4t1XJhRi0cqRxFy7EXtMO648dN07tL6v9TlY1X0oAXF4UVZOMmWe t8RAGgbsUj218k+WAuyBNtEDe+/XiQFcHwgNzc9B8txi2fA/EwEGKHhnr 4LhaMe14ilCf9S5ZgoojyKJ57CeWzjmAjux/KrhxXnxGSwzNldNMRRT12 JpxZIXG+ahGzMtwpbruUNmLYlL9c5yeaIx7of5d18CM6EveABFZc/4zlC Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="313657885" X-IronPort-AV: E=Sophos;i="5.98,220,1673942400"; d="scan'208";a="313657885" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 14:31:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="848024790" X-IronPort-AV: E=Sophos;i="5.98,220,1673942400"; d="scan'208";a="848024790" Received: from leonqu-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.209.72.19]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 14:31:34 -0800 From: Rick Edgecombe 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 , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com Cc: rick.p.edgecombe@intel.com Subject: [PATCH v7 36/41] x86/shstk: Wire in shadow stack interface Date: Mon, 27 Feb 2023 14:29:52 -0800 Message-Id: <20230227222957.24501-37-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227222957.24501-1-rick.p.edgecombe@intel.com> References: <20230227222957.24501-1-rick.p.edgecombe@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 337E4C0010 X-Stat-Signature: 74khzximu5fg9ta8b7nah5m4wjk3tmhp X-Rspam-User: X-HE-Tag: 1677537118-26353 X-HE-Meta: U2FsdGVkX1/mOx2MPPALcBEPfO3VIZir3XcNPaLVxGpZC9gNA+k0AYbUJTNRWocQU3a6AoSmVA3YPALwXIYqXUOeKV0gLXmcwGDDmmJ9Nb8hdpnPv+NE1w4OK6y1mIQb9JK+juN/RCeizW84ElThU9Qsi+DxZfgUiMPR0Za6bqdHzMcMQfIvqYt4j4zffecr202Pr/sv/DbGCA1f+dQzMx1OAJ6ZowN+m6HvE8a5byO29gnKrq4s3eKLnsM6bJlcCqXgbEAJgntVv6DIGHxGp9doiBKBaBHFXNUsjQgbvAQ/nCmY4Pb7NB5jyv8Wois+QnQTU+Ie4ZRUqHKFgDNdllOrCzRMlisRXrAVTPztu3f0bf03QCTGGy8RZra1cpkzHWxb0mUENFAZOAvNFHQXNiihdrYi83s0QnHR+t96G7aB1o7cwMZZlHdhqaPICdzehof7JA5oMuJwpz4vDLe7ozAwWjPCCSAFsUXYuiHIsby7dynz3NmB25CbMuiI2UgrL74L6rCkYTD652e951tCBB5ChUj3Iz/vlhHglje6n6mUhlS2Vzk4IddDyxkWg3VJafDd6Io0oWw6QTh4+M6ZZrgiv/H1KHKbvykJXD3W9tI7dikUaAr19hRef/mQ0IVgSyAdS+06Z34r9eXyDTJCItJjpbt2LdVNWY4mrvArbnVYDL2hE0pY8wpc2K+VNLfLBk0CIMYmivXHlEjqqG4IfXP0n9xETRhjIQ8epdin7OogzSzpJF2npGrAn02jVR6kPFQNzSIIkRDx8mQaqscKsvIF61faYYcQjtELFQqsbQ8y27DlRgarQCR3J/U9kN/Ui6C2K1PPOZQBPW9qKWCDppOnwvpU7QNRO0xtN//GwTnDqIMuQ+UcianyTqq/y9DO6U2gwrQzN0oQAhguxAnaFAQDULJFcyW6knNQj8VWNAQjZ6F6EIg/m3wgycf5/lOzMZJ84RUv6buQfrtADkX 9oxRgByj 9SaHEOglP3I/K4Jm7Z5X8C7Ujd8qpkm7OsJ9DH+0jJrXVMUONB3HtJlncZqTSXNdjw+drlOv1miY/zsdkn3Rhkr0RHKIvQztJ0KdL6Mf3oadL8iBCC9gUQE1OThqnafjAx4QHocvjcMKv9PiDFPIBvCqwAj7/9q32KLRQUySyKnIA6XMDS/MxPEa3kqFQQQ9E/enOHykyoUDRkDL0OK6rYddMupZEQMPFpZZxA7DdvQ8ZE8yIE67K7P4oq+RHxt8GwTADeA343w6FSKhgFcnNzKB/FNvcopeSTIySSIha15sG3UVTnH8iSb1uiKkdRkMd4bLMpEP+ftMzSrTWz7qTBe4FsVkS/Ci+SZ8v 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: The kernel now has the main shadow stack functionality to support applications. Wire in the WRSS and shadow stack enable/disable functions into the existing shadow stack API skeleton. Tested-by: Pengfei Xu Tested-by: John Allen Tested-by: Kees Cook Acked-by: Mike Rapoport (IBM) Reviewed-by: Kees Cook Signed-off-by: Rick Edgecombe --- v4: - Remove "CET" references v2: - Split from other patches --- arch/x86/kernel/shstk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c index 009cb3fa0ae5..2faf9b45ac72 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -464,9 +464,17 @@ long shstk_prctl(struct task_struct *task, int option, unsigned long features) return -EINVAL; if (option == ARCH_SHSTK_DISABLE) { + if (features & ARCH_SHSTK_WRSS) + return wrss_control(false); + if (features & ARCH_SHSTK_SHSTK) + return shstk_disable(); return -EINVAL; } /* Handle ARCH_SHSTK_ENABLE */ + if (features & ARCH_SHSTK_SHSTK) + return shstk_setup(); + if (features & ARCH_SHSTK_WRSS) + return wrss_control(true); return -EINVAL; }