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: "Edgecombe, Rick P" X-Patchwork-Id: 46013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp558868wrn; Thu, 19 Jan 2023 13:44:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyC2z7uAJXU6uKtFX+p6FlRazo6E7/CwPtkDJ1ilBsxkRlxGNEDxYCBty2FXnY3a5U7wNy X-Received: by 2002:a05:6402:448:b0:492:798:385e with SMTP id p8-20020a056402044800b004920798385emr24680945edw.33.1674164656022; Thu, 19 Jan 2023 13:44:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674164656; cv=none; d=google.com; s=arc-20160816; b=uqjJR2y2bNOJ/u3ed8yAXugDSqeUxfjrsaYgj2JUS80eQB/AvJoWjUKBGQMT16rpG0 ZcQUiAzplHKrWJrGzih1dx1sFq+ZVsxueuN2RNqC09ljWnw/Sc2EAVSdO4uwFrDKNs/k Htx0QZKM0s9jeW8+2kVmsQQhql8qY32iYzDySmw935b8fFnWqsIDWH83dLt/RkwwFt3l 3vGQvq8aGmcaNHIZpGiuYD9DOV3d6setPQ+5fmqqxypRmF9SecT2Ibf8WV6YogTa1ps4 fgxfuUDzTt33e3EVP2Wxray0vGtG4s6K+KzI9xBHywpNoG35+2kk9B+9Fi3iSdkZwMWv 3zfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=LARyYXf5hRWem17uRVeQYirgVhi/Ae5Eh0pNi1jng38=; b=KTmncHoUCFeWFX4Iy64gDASinkoAKp84hqk2CeTDE2x/CR45cFGoRMnAnkUXY7un9U QqHgzTaiMd3yDnQA+fDk+eHVsPV4jM7mXpyxbA06knIjuXKSBDbV2RWeFYq1F7186Qtm KzB+Bh6KW6JGYfOpGI0Fr9unUFYPgHCJYNOVBGSIzDGNd/Wex7ZeYePrKAbXo1lQEK2m ZNUL1t3MOMfHIYS5KQwyRQatMgZROJgiQ/JkCmAR0pVikpbFJMsN4vrpqmPybG2qIuAQ Sp5J8scGpp7eGkmgojGsf02w/l7+uX3XHj5dwOo0WXZ//sANh72S45fyA+qgqCCuk+vx IVuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P2OoiS+h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a056402525300b0049b63678b4fsi31139994edd.358.2023.01.19.13.43.52; Thu, 19 Jan 2023 13:44:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P2OoiS+h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbjASVnQ (ORCPT + 99 others); Thu, 19 Jan 2023 16:43:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbjASVik (ORCPT ); Thu, 19 Jan 2023 16:38:40 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F40737544; Thu, 19 Jan 2023 13:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674163678; x=1705699678; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=sQY1E+dUSY4CcT1mmXrJaIQvOz4XoIsJlzVbJWGjXhw=; b=P2OoiS+hwDLY6GdBku6zRAS/PkdSptjlD6Vzbo/ybb4J8U3Z2faRDQTQ y7Y58C5/UzgZQdbaJF6nEJb4SXz9RbaDE54LE3IsB/m1/DLsNKnfxvFrk IAhUKoE50LVd6Z07EXbCUDoZ3golLfZ6xyC/vAjUyJhLZeLZFNIL5mFRx WHh/i3YGvQOetdDHHkvbYFQKZdvZKPyvGchG2EzRAuxumMTWUtwLKsGuZ vomDaCwiS7/uj/KlKoeC6LAtP2hPIY3MyMcL9r17WApdbg49TF0jd3O6x 7f8HBYybAU/qSmVH3GKaWiVyaa3F7HJVVsz1d9urOk2bKWUvnd0t/HGSH g==; X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="323119994" X-IronPort-AV: E=Sophos;i="5.97,230,1669104000"; d="scan'208";a="323119994" 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755488878222398312?= X-GMAIL-MSGID: =?utf-8?q?1755488878222398312?= 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; }