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: 29194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1143377wrr; Fri, 2 Dec 2022 16:44:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iKOUYJ6myaSNtSf2wbtwz/gxSoVUL/c67Y7DUy8EemuLlmmA7WbbBOQ4vJJwEd6biMvSa X-Received: by 2002:a17:902:ab8d:b0:17f:8232:257a with SMTP id f13-20020a170902ab8d00b0017f8232257amr55558367plr.138.1670028252299; Fri, 02 Dec 2022 16:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670028252; cv=none; d=google.com; s=arc-20160816; b=tKmhds30o9m9ex+62nLGjMQ2BRcj3j/sJ2SjzOa7g5Bqi685bdLdwrpKMek2W9jZxg pPn1e9FQ15GRwlVybVuca7Go407h/ffQ04UpY5kcyQP7v4IJ7rKV1fqRwzPda1gZlgXm +qhVw8U9t8LCHp0Xuoy72Dh/AflSwq4yCp376wwEXYCFSruSgsPnTKaROzg4k7Ma+x6K RBWLLH3Hv3PsvIIqv+/KHVYHwPa2FP0QGB44dYTSVksGNmVFG3pAvYWV4/5SB0IL6by9 X8dnJJPg9DOXCib0FNdq97YZhD/AIW7cZPI7jB+pRSNBc841lbMWItQqE66J7CsWCHPx IjNg== 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=uvxv1iubneua9nCs2uvSGpfhBBq803f1R3WCljoUdUo=; b=VpoPUsK1Uvcii8Mr/NtIva1v1Xwrd/1ZVArBW2SDkYlf+MbeBYblUvD2FNpKZjGoWh ML36Y4LoygKc47HHoZHQRAQvwyQmExPumItn83z4HxqQl21AkDs02gr1WwsLeXkWD2Ty YfkwvNSyxkQpWRooOpzDQF1WRvDxPzFNJc8clfQNexnA88m9uJ2BGO8wGrP8ln7OLolY y0GKLGgNwwxKzYPVpjS5vCWdNM8BKMwi052k7LicnZ/CUeCDtF4PHuGqqUSF4u7yG0Mn /Wa7Tvdg35WN/rDhZQjMAPZvs9QsvKJLvZVxOxPyoU3blarZyoabAx+Bkx6Hv8UUcGuQ o6hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MACDcLCH; 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 h2-20020a170902704200b0018930d070bdsi7830128plt.72.2022.12.02.16.43.58; Fri, 02 Dec 2022 16:44:12 -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=MACDcLCH; 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 S235001AbiLCAnn (ORCPT + 99 others); Fri, 2 Dec 2022 19:43:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234980AbiLCAmF (ORCPT ); Fri, 2 Dec 2022 19:42:05 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596E3FA451; Fri, 2 Dec 2022 16:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670027912; x=1701563912; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=tLQzvtFCG7gPr37x5ob+Amj80mPdYmHi/Bjvakhw+Z8=; b=MACDcLCHEH3KqhNgCMhCN9N6ImoxZTG/+c71XeRUzK2pvixCpU9+rdeg uLm/R98OeQWCQW95iYfcmQOTYpSCDCr62MiIxMJ9sUJDAN35mCmc/rYz3 ceBDHy914aIGzz93MHfZQxBuCr9xGdXLumvRvNbYxAWWjSpmDiidYN6KZ 1MwlNzHQmhwE2z7KQt6L3l3cw2FarSDWdC7P0QxIjtLe+rTBnHS3w/nL9 yOX5nW+5J22ek9XZoGzolFI5cEH/lJj5f4UpNAyUFa/uvIxHiHDdDpgAy v3PVil9NziIFXNJHlW1HQPBFa8d3WtHyoVegC7il+th6kt13FlsG8baCz g==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="313711538" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="313711538" 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1751151544604757957?= X-GMAIL-MSGID: =?utf-8?q?1751151544604757957?= 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; }