From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92812C43217 for ; Fri, 4 Nov 2022 22:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbiKDWpR (ORCPT ); Fri, 4 Nov 2022 18:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiKDWoS (ORCPT ); Fri, 4 Nov 2022 18:44:18 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2DED69DC9; Fri, 4 Nov 2022 15:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667601638; x=1699137638; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Q2WzLNvi+uaoeKQh1K+WrXv9LEwAcETs+iDQvlLduko=; b=Vc4tgZY0ip44QOpxBsqsdiqaUZCO2swDxmZPeHTlUtrL13P8ilbtEUfp zi4mTrOAgCmFRkvQ9QSI4G7f5jCVRdeybQlcU7r5UWhN2PwdySxThqmHK Ks/WRpLl3SUOE8BqKvMok24fvI3MzPl5QpQwAeTbSrA09ht/GXd3mG/cS E7+7l+NNmrUlxyAXRZiHWZVitZLA3X3Cfj4TxFl+9AydC1iHMddOZY7Z/ kR8oGcR5oOFsTKqIFq4x8CnvWa3gxARn+PGbw5Dfiw2Nl9ZDriIkzyRKj Gxh+zBMRbSmA8nx+94ad1ERvYO8M90DPYh68HMsv6T2T/hoo/YycH6SH9 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="311840607" X-IronPort-AV: E=Sophos;i="5.96,138,1665471600"; d="scan'208";a="311840607" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 15:39:51 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10521"; a="668514147" X-IronPort-AV: E=Sophos;i="5.96,138,1665471600"; d="scan'208";a="668514147" Received: from adhjerms-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.212.227.68]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2022 15:39:50 -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 , "Ravi V . Shankar" , 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 Cc: rick.p.edgecombe@intel.com Subject: [PATCH v3 32/37] x86/cet/shstk: Wire in CET interface Date: Fri, 4 Nov 2022 15:35:59 -0700 Message-Id: <20221104223604.29615-33-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221104223604.29615-1-rick.p.edgecombe@intel.com> References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org The kernel now has the main CET functionality to support applications. Wire in the WRSS and shadow stack enable/disable functions into the existing CET API skeleton. Tested-by: Pengfei Xu Tested-by: John Allen Reviewed-by: Kees Cook Signed-off-by: Rick Edgecombe --- 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 cbd0970b26d7..71620b77a654 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -463,9 +463,17 @@ long cet_prctl(struct task_struct *task, int option, unsigned long features) return -EINVAL; if (option == ARCH_CET_DISABLE) { + if (features & CET_WRSS) + return wrss_control(false); + if (features & CET_SHSTK) + return shstk_disable(); return -EINVAL; } /* Handle ARCH_CET_ENABLE */ + if (features & CET_SHSTK) + return shstk_setup(); + if (features & CET_WRSS) + return wrss_control(true); return -EINVAL; } -- 2.17.1