From patchwork Sat Dec 3 00:36:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgecombe, Rick P" X-Patchwork-Id: 13063375 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 B62FAC47088 for ; Sat, 3 Dec 2022 00:37:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 342AA6B0085; Fri, 2 Dec 2022 19:37:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FE5E6B0083; Fri, 2 Dec 2022 19:37:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11BA76B0085; Fri, 2 Dec 2022 19:37:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EE1596B0082 for ; Fri, 2 Dec 2022 19:37:45 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D02B8AB7BD for ; Sat, 3 Dec 2022 00:37:45 +0000 (UTC) X-FDA: 80199132090.19.5FCB7B0 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf12.hostedemail.com (Postfix) with ESMTP id 3B86640005 for ; Sat, 3 Dec 2022 00:37:45 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=K0hkIfHH; spf=pass (imf12.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=1670027865; 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=uvxv1iubneua9nCs2uvSGpfhBBq803f1R3WCljoUdUo=; b=cTVE16Gi92SBKrQb2MqGoaypXY43GtyCojmOa5E4wxcQwGw4tHwcgRICg1kE3qHzdP+B6A oKUaJCEQ4GtwFOqsCo23708nmghQW1SPtJNiNNzeuuU9n4tdXKOQlkjlqGAZmucrDz+5Aw UuLpvPjPdJz4ERRM/tqlGkgh5UTNwpI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=K0hkIfHH; spf=pass (imf12.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=1670027865; a=rsa-sha256; cv=none; b=lnVuE7n2OAKC3lHR+TyFf6prgLHadjM6G4Pj+1EXncuR+hsZEGtA87r+iYK0mUfqyZQSQ5 MqYTrwyzi2skYOpweRp+BxqORqRyv7jsEVePlhDlo1TPK/+Wt2P1zol3z6fH2K6py14iDO QfAc6HiRtJnbdikaIwb6n4qB0JF/Fio= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670027865; x=1701563865; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=tLQzvtFCG7gPr37x5ob+Amj80mPdYmHi/Bjvakhw+Z8=; b=K0hkIfHHJdPdSz0RWNOtRqnYl+XRcJsvlMcIShKXrE/vddPZvFmC/NlO nHSYSJe4jmFnvFghsKukCfb3f+nRamuS/poiv49x6VnbdtYOWlwlo0GEQ 6904oWA/i00x70jDAGOQG7xWTdlPnu9UtCGX5AOae3orzw+tVxv3Bj8dv xnDT+/bMhOpGEFNtlD+3TTsSjvhqn/oLSsbM3GX99wycIdI3kSYMZhYlG NESrAjwtQq3a0YTmG1Xfo0y1DzGIHTl9JPErgE/cAwbBsoAguZX1HuQx1 wisMIjcP1mrG4UY7woNFYVn1H0hChZiAUfLhCJVw7tFErK/wbOJiPg+tI g==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="313711542" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="313711542" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 16:37:44 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="787480020" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="787480020" Received: from bgordon1-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.212.211.211]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 16:37:42 -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 v4 34/39] x86/shstk: Wire in shadow stack interface Date: Fri, 2 Dec 2022 16:36:01 -0800 Message-Id: <20221203003606.6838-35-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221203003606.6838-1-rick.p.edgecombe@intel.com> References: <20221203003606.6838-1-rick.p.edgecombe@intel.com> X-Stat-Signature: i9gmdpfruy71u37dyofy9qf7c7omrsun X-Rspam-User: X-Spamd-Result: default: False [-3.75 / 9.00]; BAYES_HAM(-5.35)[98.56%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_ALLOW(-0.50)[intel.com,none]; R_SPF_ALLOW(-0.20)[+ip4:192.55.52.93/32:c]; R_DKIM_ALLOW(-0.20)[intel.com:s=Intel]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_TWELVE(0.00)[39]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[intel.com:+]; TO_DN_SOME(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 3B86640005 X-Rspamd-Server: rspam06 X-HE-Tag: 1670027865-428266 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 3a7bcc01d985..5d91e653f77a 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -468,9 +468,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; }