From patchwork Sat Feb 18 21:14:28 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: 13145675 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 15715C677F1 for ; Sat, 18 Feb 2023 21:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5960A280023; Sat, 18 Feb 2023 16:16:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 56BCB280019; Sat, 18 Feb 2023 16:16:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C0B1280023; Sat, 18 Feb 2023 16:16:31 -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 2480D280019 for ; Sat, 18 Feb 2023 16:16:31 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0313A406F0 for ; Sat, 18 Feb 2023 21:16:30 +0000 (UTC) X-FDA: 80481671382.12.266BDC6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf16.hostedemail.com (Postfix) with ESMTP id EED32180004 for ; Sat, 18 Feb 2023 21:16:28 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=k0vC8x+n; spf=pass (imf16.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.43 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=1676754989; 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=DReRSgvy6bwQAJ5021aO9D5VPOmaKRsAP7JXRlEBPpk=; b=o8j0GDWRZxHXkg44YSdLkaFBvWb98V8uJYCv5pWq1sFPQOOWL3eGmBvh352dukTRY9nLD0 IqamZNSTKFbquoPUHPdUL6+tUiNmZjmjB2zzSxnPyZ2Rwq14VqfLXuDIluf9laf+1MUQMX sg4IdPz71pT6RSg2n3QJ/KtNh/VoFwY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=k0vC8x+n; spf=pass (imf16.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.43 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=1676754989; a=rsa-sha256; cv=none; b=mb9d/1uwLyPxuj/IYgLYw4UK0Mj8freaq7DsdIc/Di+/+kUToG87xm4roxNFkxHQDqKxbs slDvZoUxeivrJHwXg2LjoRCLKVHDfk4mWVL1Sxitk+Bm/ELmi2Arom3H07SaLp8ChG9xt7 u6eQH4VwFvlZ0HkSSjzYeUVWy7Jd/KY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676754989; x=1708290989; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LBXMAmJiTfFh9q2evgIt9WapwuhYib2Yu77ryjdrcH4=; b=k0vC8x+nqf3FSH/UI5HJo4M3Jdd91vlF+JE5pTUaJO9uaA6RXrp/a9zo O/scgu/a7U+3+I9xnzazn7KzseyN45wy9aKFoUSOU4l7EZqMdjsR9Vnqi z1CZyhB0IyNQtcUoViD4xKoh12zdZpbDiPPd88YRqdg3CX/z1/Zy5e8yf wfkx0nBjMcgx8dLDPWfw2miD2/A1qSsJTEr+1HAsqQFmt5hh318Pvgs0f H0ms0XnJ5LS6bzVH4SwfTvL20ncMm64V13kiwaqHFm9ALIv69p0/f4JXu QQt4wgsG4L8ckPCCbe2RCIaIOEUzfwr7qSssZc0iuMCVZoVdSgQzY4pJ8 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10625"; a="418427871" X-IronPort-AV: E=Sophos;i="5.97,309,1669104000"; d="scan'208";a="418427871" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2023 13:16:26 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10625"; a="664241745" X-IronPort-AV: E=Sophos;i="5.97,309,1669104000"; d="scan'208";a="664241745" Received: from adityava-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.209.80.223]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2023 13:16:25 -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 v6 36/41] x86/shstk: Wire in shadow stack interface Date: Sat, 18 Feb 2023 13:14:28 -0800 Message-Id: <20230218211433.26859-37-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230218211433.26859-1-rick.p.edgecombe@intel.com> References: <20230218211433.26859-1-rick.p.edgecombe@intel.com> X-Rspamd-Queue-Id: EED32180004 X-Stat-Signature: fjd1anwxf8wu6xigi13aspwa95y8p96h X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1676754988-488089 X-HE-Meta: U2FsdGVkX1/7/xSIXlcYF4F+Jm25sibEi6eoh1noSdiOKK+iHs5cbMEU27ThikFh5+k4Uia5H8RZPhm09msDHV5Wgdu3Q39aeMo5C6Ztxk93QMplIgBVhO7YYprJc0BHs6sH+mWa5GTXjImFVeMAKT7uQGxj8l+H+6XGFhE4BOi6r/urE4DK32vKk8dYmor+zFLlV21vkL0ssoj4NZLFgU9qs5/R+cFSvbjb/DHawVCiEo6JSnmRHivtZOoo/vGt46oPTGYKC/EqT7umlSubnyhJpp2m6GlK1ez/GohfDou0Q0B5NcS6KnS2r+FQxWGLc813eK+TsOvxgV9aAuknaw/Qb5aLK1XO760HYUbiHcNh6FpG+yBQeWytpPwGRUthLJ4YWfYREzj6mDrVEBDED1AEThnHBEeftAGw0E6WcofvzJ7+m7ozMKPFkBHvpgoJNXypzCqjFbC3XWke3qNwn/PHCGyys2bzOoGoD3XdoltdGdYNvYHFHvLy/vfNM4nYTWj4VB4PD31HYBqUzQAmXEXqU7dO4/KSmrE+rIZMzHLI6gewNYBSpVvk3HcJ1Lpatu5InzCEHU0YBtk96yMNioWOAAnEWHbx2qdzAw3nxjs30mwOX21SnfDss24VOc8JZymGWE6jKyexvcoTW0e7ao8nGqtnT98tT317vEcteZsxh/2DVBJQoFRERHuSLATXn9BpF2Xqb2+8NSgPwUB1ssPBgAQ0jyn7otKTZ2Am33QE00WIi4std5Ri9seM3mKsLc7RYcWWwVbWzWJHqkdv5ZFxoCC0QgyHmiZr4rtMzEHMw2q8su3l48rNdlstR7Fj43SzxxGR7aV/yMwdl+hG8LdP97x1CYDP8cqE1/yKa/TLDCd1EfbJZWkA6ZpeY/bpumcyzIvdqj+m3enKILfQ6F6YYxtEWv8yh8Fw7R3ov9htuW03np2kiGgv9rNwlQG41KU/qG9SsPGuxWhOH7o u2qQQDX1 41kfYABrvQDKYFNTQD1R3sWQaAW+N6InsFnoSCoEn3Emaig202gRzE3qND0W9uighHs2yXOosRmHYnwUp6KztzVhtTrZxzmb9CqGkaMtZ3gHZ3Xye8U7atM7Qa9eintsVn1cQCGftnwpmHRSssmBnwcK8QlO+epcTEWajmU2e/hQ1tFmEL5pkoCL+UhkBku4TO62fmQTAF2b2ykZbDf3T6a8WEP3WhDS0gO0yxtNOPCF8l/zJgPfXCq9u9qMoNws0jx0OVJmAfxsFS1kUU62wEkdGbsVFL6wI8pSc 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 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; }