From patchwork Tue Jun 13 00:11:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick Edgecombe X-Patchwork-Id: 13277752 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 4CFBFC7EE43 for ; Tue, 13 Jun 2023 00:13:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAC358E0026; Mon, 12 Jun 2023 20:12:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0CF38E0023; Mon, 12 Jun 2023 20:12:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5FA78E0026; Mon, 12 Jun 2023 20:12:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A40E78E0023 for ; Mon, 12 Jun 2023 20:12:44 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 71C23AF63E for ; Tue, 13 Jun 2023 00:12:44 +0000 (UTC) X-FDA: 80895798648.16.A91CB6B Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf19.hostedemail.com (Postfix) with ESMTP id 3FC8C1A000A for ; Tue, 13 Jun 2023 00:12:42 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Q4AVEeq3; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686615162; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1F1/TF3ynb464OSVq+cAxAGFjNLdRbyulxUg251OjE0=; b=0HZ71NeWuxVAWebQNTEr6eGgGVat2qQFDJ6KuXow/vNqJ1iFUVB+yv0ryUwX3XiyALU4+R Zsc616EZvX8vLtYCB6g8PmWKzm3WmMy02oNo8tVa6M+NbBRH00/6f8NbuZtWf85KAwVm8E D/fTIm0FgNBo3HQGPRyLJoExPHg7cDs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Q4AVEeq3; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686615162; a=rsa-sha256; cv=none; b=OwG5l9dSbafsGp5Kk+XPDrKBTo5t6hTqR8lVmgLQB0rTWXsRjb41nwe4g6G7VMuhiBuPz1 OMeHQhoVtdabFLRM25nxqYOF8RbYywmRm9+xg5AwXmGI36cBiwzkTXiKx19tx70LZ1qNax cv/c7PPOfZGZ9bPry8KBb4cbpK6Kk8I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686615162; x=1718151162; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xI4pbs3PiOhFQEbuDUq+4GewOhti2Nle1TQJwXiYqGs=; b=Q4AVEeq3aopZ432IPSpI0EqU0JJ14KJVzEp3IU7QemWyssNa7wJB2wz0 8zZZfoDTYtfuWgT+7NqKCWIglNcOMrBHbKikcy0Bk9oA8fuydNzjhrUXC LXE9jkUNs4dAy9KemE+iPV8g6o4ZYMQs2OkE0T3hGKlMZCtM8F/QOM8WG zUAmJ9g40iit7iZQuDgo+s3E6JKYl53bU4fceNOOZnT+0KKHYyyKxkABu 2KLf3molqHFANaqE7tyV1FvapxIObJ/J2PUd/R0YNrXkt/U8Bj/Ih60v2 PDSGhq5mCRPhCdlisseCaizpvguRfeCrfLTOHaSoVc50a4wXYApo2Jwsl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="361557551" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="361557551" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 17:12:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="835671152" X-IronPort-AV: E=Sophos;i="6.00,238,1681196400"; d="scan'208";a="835671152" Received: from almeisch-mobl1.amr.corp.intel.com (HELO rpedgeco-desk4.amr.corp.intel.com) ([10.209.42.242]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 17:12:39 -0700 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, szabolcs.nagy@arm.com, torvalds@linux-foundation.org, broonie@kernel.org Cc: rick.p.edgecombe@intel.com, Pengfei Xu Subject: [PATCH v9 37/42] x86/shstk: Wire in shadow stack interface Date: Mon, 12 Jun 2023 17:11:03 -0700 Message-Id: <20230613001108.3040476-38-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> References: <20230613001108.3040476-1-rick.p.edgecombe@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3FC8C1A000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 96ekcgqht1d6x3oz5tw3bokq6e3y6tjc X-HE-Tag: 1686615162-48834 X-HE-Meta: U2FsdGVkX1+7Frz4JDC4wIMb9/oTrpie4Ddnrxr5vVWd3yVdkm7NavwitUlpF8m9FeZAe3jXOETo2LkPkcAX7/LYeFQaMT2IXxkiBao0mtz8ZLPy7MvH1Jw19YZR8AsTosdnjAJ/YPujk1lFBcfzQbTjzUBqAweXqSgrogiUSvs1E5KItbRHpJYA+y3O6o4QM35FJZ0k5DXTx98iE5J9j7wuua2nKVNisl3yclawRx53CLGoQwSour0uf77Ca8WS6SCyPtY9zL0QFb9cv95phIqDJLMyrc8s1eet0bCLzUs2i0E+LWkHanJN5WNchvJRpfcHptMwhtbeaq/wxgCI6yDEXlIuxqbtARjKv4NsSTLNyaeh1Q1KouAennVgABPHVJ5prz6IAsPjBEoRKLYFzuBkFKyO183e1df4jpR53UsNt8jOmqdWiLkpMdO/sYMtYbIMRSv1BECrjH36SBDYI/ayQuVBXVhH7oBRByIB3XRyVCSD2n3qrozrHfQ+yp0KVkyUxdFz6npK3lP2PxwI7E8qZcRUPJ+h4DkOAKtjOIUM/3/J74xrx9i9yxnARvuDMPCUidqsRw87ogo3r2rJICzcfwCL26OWXFpS11NrAmVb9ZCCsCFY87y/3NSQViqTEFfoC0/pVRtUqfnXoh3rvWvsN9jPm1b+fwcWdMUQ/w4ppew+8JVSw0J25cBcH1JzBF4k5VihINKQYDwKOQZf+oGC0rQ2Q2ORiRJ21surLDa66H5JJZ9dSoBhNdjE0kxHDJl2UxcucnUQw9iYU0c5rH2rMhAceGDnNvzqxg65KT57hYFFvm5W2QcAzG243ZzH7mnAlW3FifXpbWfUMNAB+Y4/GP3Kg2uKM4aU1QNPqyIWHShBjc5anervluTHijtDw6pGG0Lr15/9lURyMo/C/A2D57D/EyaVMwYryYl44Y7lRXlDJn1icZ1Y5RwEpgFuxVqiq2xMX4FjHjED8ou iOxCaGsL H1ND9TD2LoYs7hYx3Kkuy6nAGKbWer8WiMoDKreEchowvM9Cr0pcwNjNdlU2z6otapCa4cES3lXngUw6zI7g6VKzVbNGCu5hAJ9j8iwCdI1UFsZkwIf50cvWIexwrZarIMzXm1owPQ81Pp8PE0MmkzZET/2N9kuC1McBZ5YjheN44VHPVA3BW/77AzL+lxqfY5roje3R9dcLn0y3H2ZUJuCTzbvvfzbNN0VDz9RvdLITx0ZZLEQLHef9yAUoUIO9ViKBw6QUKnEH3+YFhi7sCLNgAzVAYdaVKyux9fzTn7JUSORUN/wPwvbta8yvAocCSovs8PkjDrdt7WEyGryr5EjLoqhmxgJTivkuJHlGKGdKui8qaa3lxg5YBkg== 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. Signed-off-by: Rick Edgecombe Reviewed-by: Borislav Petkov (AMD) Reviewed-by: Kees Cook Acked-by: Mike Rapoport (IBM) Tested-by: Pengfei Xu Tested-by: John Allen Tested-by: Kees Cook --- 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 ea0bf113f9cf..d723cdc93474 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -502,9 +502,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; }