From patchwork Mon Feb 27 22:29:52 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: 62187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2683764wrd; Mon, 27 Feb 2023 14:37:32 -0800 (PST) X-Google-Smtp-Source: AK7set/pMxFny2TNv/rNeC1rhhjyUdubOsFT1nElIEMgDekmeNq/+xTeXRi7B72X04tGxeEBIgde X-Received: by 2002:a05:6a20:b930:b0:cd:7d01:7654 with SMTP id fe48-20020a056a20b93000b000cd7d017654mr978582pzb.14.1677537452499; Mon, 27 Feb 2023 14:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677537452; cv=none; d=google.com; s=arc-20160816; b=olq7fiohnJSbdI6KUJ8HYRrKfkl5Zz9nkqVO3HtsIUdV7UAsPnNtC7t92fundL0nYc R1iL3jJ3pWDKlxFch41NQcBoCxCtw4iGLGSE6KIuaUG8WWqY09F46oa1BiElFmW+RBrZ ij5UDbz6FvhT7B1MI+ChcCu3kX143l6g6MsJjokiafq2gkIKeh7hXzepZg+GxomKJWty 2XbPn/lafhOUxWmMM7+FLpbq0kqoTtuDG0YbHiEfSaPNMehUOuWhvdyL3T3bSVoocMJZ Qc7ePBJ19ylLq9mgB1YGBYF77nEHE6BwOAFKTgVIJGM9513JZkhfH0N4w3oOyF2Ps6Gk MSNQ== 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=LY7sRJ+HhyH/fRQUu6yhwRH2pCUOOjl5GAOCVlgILp0=; b=B4BJ+n3coekp27qV+x9J0eXUkk592GMf5h0GJA0UhQta4jdm5wUJpJ3HLQ6/KOO7tp vumbmlyiwH84ft5kHCuUiOJmQ4oBraL7BTRCfC8SHkv9yqoeZQL8aieqET+KhzOzPfbV a6RAClSYM9pRqjFoh19MCvHlWKod4JMWdMSyVFvinFQ4CjgcpTnhGseyy60QE/d3vUBL U6JILajnOrmM8MhZSfrP37i5Oek/XKsU5IaICKiw2R1r5RVq8oGF8qQ+DOOW1jYwZih0 V89nZ7W8/ib/C1GO9nss9cTD7RySrSEuN8XNbOgdtMYo0c6O1pwl4eAW6/iF+gWvgtS2 J6Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VA1ab44a; 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 l191-20020a6391c8000000b004d184dbf598si8117729pge.519.2023.02.27.14.37.19; Mon, 27 Feb 2023 14:37:32 -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=VA1ab44a; 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 S230492AbjB0Wgy (ORCPT + 99 others); Mon, 27 Feb 2023 17:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbjB0Wfp (ORCPT ); Mon, 27 Feb 2023 17:35:45 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F2929E24; Mon, 27 Feb 2023 14:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677537140; x=1709073140; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=u0fpzllgXo4dayZIZ+QVsU1muHhaSbmjAoWT0A5Xxuo=; b=VA1ab44alTpLq6fz6hYzI0stFEBnMt7RXvaAx1xme889WQFng8zRMAei 1DmKu/ugMb0nYG86PXN1ICm0fNtXUopSyfvPn15Nrra52pivMYR4jmVlx mISAHb5jEAMJbN+wHuDfnLSfdjHpE3rCis3Uv5SP21Ep6tfqLTX1muXUh rNEOhF1ysXSRdYrCaGQB6kbejS6VjoRnVNltniv7amuug5JypKnQOiuuO afJLb6DCE6aVgVOLJWWKCc0b7xCxFVMWtlMq1OUtwl3hvTMjgPnbGe++7 HJ71S0OUcs9UezreXzD4RLNAHVP/H8Ygg9zBiBa/hGsLx6QZqyae+xs5S g==; X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="313657880" X-IronPort-AV: E=Sophos;i="5.98,220,1673942400"; d="scan'208";a="313657880" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 14:31:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="848024790" X-IronPort-AV: E=Sophos;i="5.98,220,1673942400"; d="scan'208";a="848024790" Received: from leonqu-mobl1.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.209.72.19]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2023 14:31:34 -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 v7 36/41] x86/shstk: Wire in shadow stack interface Date: Mon, 27 Feb 2023 14:29:52 -0800 Message-Id: <20230227222957.24501-37-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230227222957.24501-1-rick.p.edgecombe@intel.com> References: <20230227222957.24501-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_PASS,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?1759025511485846228?= X-GMAIL-MSGID: =?utf-8?q?1759025511485846228?= 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 Tested-by: Kees Cook Acked-by: Mike Rapoport (IBM) 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; }