From patchwork Thu Jan 19 21:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick Edgecombe X-Patchwork-Id: 13108812 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 8CF57C46467 for ; Thu, 19 Jan 2023 21:24:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FE9C28000B; Thu, 19 Jan 2023 16:24:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6891D280001; Thu, 19 Jan 2023 16:24:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B27F28000B; Thu, 19 Jan 2023 16:24:22 -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 31A9E280001 for ; Thu, 19 Jan 2023 16:24:22 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0932A14047C for ; Thu, 19 Jan 2023 21:24:22 +0000 (UTC) X-FDA: 80372827164.28.8EA6DD4 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf16.hostedemail.com (Postfix) with ESMTP id E7114180019 for ; Thu, 19 Jan 2023 21:24:19 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=NZgTc1jt; spf=pass (imf16.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 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=1674163460; 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=LARyYXf5hRWem17uRVeQYirgVhi/Ae5Eh0pNi1jng38=; b=iKzW/ska0zeTKj3BIxU2DRShEySIf7Yoz5tZljHjkUNDDiu+VTAMiPTshAKbnEAczK8RH9 6Jlxg+QezbpMJyqreOh1zXPTG8e52XowLx6OUpnUr2Mwo051fi+859eodr6VmTlUTr0/zE U1j/s/2ig3pHYzR3P29NOHvqtJ3z6so= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=NZgTc1jt; spf=pass (imf16.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 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=1674163460; a=rsa-sha256; cv=none; b=6obqklqcuRFTl+VQm3JJrBydwb/5JWV60tIIys8jnbukAiobUNmlw32fXJ+yhYVcFniiKN md2CtcL06PvBwUqACRtPgN82BN2Szs5msW0D+Lv6KB6S9uKQ+HswDi8l6CVQmjlCpITpTL b0D3QKyFyilauJ6cBM/LWtlxOHzVC5w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674163460; x=1705699460; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=sQY1E+dUSY4CcT1mmXrJaIQvOz4XoIsJlzVbJWGjXhw=; b=NZgTc1jt2DsiaWUvsDhRzRe12ovOKWRrQgpfkNqdvTI2Tr21JIe89XtO MJJ36Xa2zx1zeGOQbnyC0HD4fV8cVsWOILZsyHN8FK4WaJHFunaYMYQ9u Up98qvoMoAIF+I+DmZWO11SO3uI1awVKWkenCU4XZ6QqA3OjB98EqmTSb 1CVOfZr+S20a4GfzvBTuwLSQc70Bq2YtAe5JhbCQPUZwciceJ+K8fom8W lTkMGCMuMoIACYgi1iNbIDLI9hjlN1m7Xp7meOF3ADNLmprCD5BCJdPyA 2hHkTXLnuTFqk9PZfJlmu6ZwK7TGmpPG10VsopkrkXH7oaittSYKMP+Tb g==; X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="323119998" X-IronPort-AV: E=Sophos;i="5.97,230,1669104000"; d="scan'208";a="323119998" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 13:24:19 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="989139174" X-IronPort-AV: E=Sophos;i="5.97,230,1669104000"; d="scan'208";a="989139174" Received: from hossain3-mobl.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.252.128.187]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 13:24:17 -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 Cc: rick.p.edgecombe@intel.com Subject: [PATCH v5 34/39] x86/shstk: Wire in shadow stack interface Date: Thu, 19 Jan 2023 13:23:12 -0800 Message-Id: <20230119212317.8324-35-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230119212317.8324-1-rick.p.edgecombe@intel.com> References: <20230119212317.8324-1-rick.p.edgecombe@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E7114180019 X-Stat-Signature: hgnfiw7pso13x9timr8hwhwxayctopz1 X-Rspam-User: X-HE-Tag: 1674163459-960724 X-HE-Meta: U2FsdGVkX18ckPHeD+C7k+ealdHAklneaNEkfZqpA8m/pok+H9ky2JKcyqjJquwZeBLkJFKf4UuthJlDMUQqkDwe6E2potcTwsfwG5qA7OYez0leu0uOVc44nWqqLK4iR6Tsdmwz6no/PwCbfPOfLY7O/tbXt3D1Ea8EQttSMrcC07mq9pnRKdNS0gWZXIjm+3rJkthKw0m6wK0tnFjmDeD7xQsRrDPeF7ou36oMxh875liMEr+5/2LIUJw5hxRbvjx30KMjwsTqP7vWMHgzrj5f12cSHrwfY7GfimWYJbhvVmMO4JdRZWC5Qsaf3dhSrdNYKzP9/MnaHJcKMPkPKKu0XjrEWUPEbol0UNTt/B362qMGTwZEvl0zRIvRfBMFjKhri9EZdY5uIL+VzBKxZOtr86qk/ggFg4jVIvaBu2ivln41ullSF/mtYWEn9bbCRTFAgiz3mKS9Puu1jmXezQ1Y0xUPbjj2l0HQNgEwoRwqrx0mx0ex61Om/cV6oLkkpWTOtaebl0/FB8RmAJyes1ADvjuPEYHvA7SS5IMv7hxW72mwofv7y2qONAqwAJ/dyxGcNqKQf6RjP+qmVQQA5iKYjX58x72Vp0qJuAe+fLp7SQedGRiBtHWiypIQcRO3meAVLIEePdUrlNrFShVOhytqrL0kkcydXkj64xgCIDY37LTZtjbJtR7wzCeDKwdt8+xdgYdxwE7vtwmhC/yQvuVyMp1Pr7+l4SvBwabVxGnhitHzvuVoqW0sCo1GlbGawz1CdnK/x2KrZAjzuGZn53cxYWNKXLC3RkiNszb+ccfeZZqzS40YzaAFTkQ8CsXJM0ZkfkyEmgCkf/Ho5YzeMXXTH0Dq4BZFcsTP6R46JwvTyRWe+J0Yj5XsEIUEln/yeCGOEz5wftx9XrIEfOacqtW3UQ1ncwmeqaHrPBOl1V9Q5QaT+8SI3g2MKxeMdeRa0K0UMTRZB0oizRdPypz MEkJvook juS2VjHFZSEYGynqHE7sBAE/HETyMioscCfqVrFqEHVv60rXaHMWZs9m9y18CzE/DZgGQWZpsjE3eDv37X+tBIup2hZUsBJEyd+xa7z67L3ETtCNKESzH07qMa/XsykcxCH1HMzjloqYzJ4/DPlZSsxeU7TfmQmqhY/9JnhwAttb/G/dJXFg5fDtPrj88mStIqTdGZw87KmfkxRLAg+21e+h3uUgYIM+dVsXqF/nAwUIY1ecDB8EP6Jlnq3Ar4b8J0yJkPjGsEo8qlInaAZOq/nEKYSIXzqmwZHQC 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 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 71dbb49b93cd..07142e6f05f6 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -465,9 +465,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; }