From patchwork Fri Jun 16 19:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 109345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1571806vqr; Fri, 16 Jun 2023 12:37:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4OQpuFsCO03OprsNscrQt0lgC5Kgqh82M8L1dZQM6/k10yvtNHaQSyh1lgo1pP2ELeEfvY X-Received: by 2002:a05:6a00:124c:b0:64f:c9a7:a809 with SMTP id u12-20020a056a00124c00b0064fc9a7a809mr3061257pfi.6.1686944255263; Fri, 16 Jun 2023 12:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686944255; cv=none; d=google.com; s=arc-20160816; b=eoVAGWCpXU40cVSjvZQFcjpGG5D1FbaCCwPE1KNJLcVS8Y05evJG1YADE11Xvio4/5 DfDUw5EIwjVSUGnCYDFAZrUYvDM4r0ms5xjNYH1Zha9K/ugW4PHjzUQV9JUdLag09TRQ 9auJdsMValjgkSswkderTJtL8DDdh8z1lSeGUw6StjFC09VIVssy5XzUJbcpYajGelGq CDa2Y6grd/CFjXWnB0MzH9WIuaYt3KGQJd6FGuNNCnrjJ7FbyALRmu+0vA1t7rplgL0D NUdOIg3nvEYjEI58rzaZAPWa2/QtplI4ffHT9eTIdfcUOErCJephED7nI6ddD/+9zKX2 4OdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=iovYtGDAR/iBGfQFTuKy+OfLY4uRUPtPAYOMshctPE0=; b=0uSjR3vt4WBKHCENmlz3rxMdXfs1ZSxslHMWz6Xc1LVI21/jGr+EcSd9TtYji3t+RV 3FJl3lcDyv9FoLqdyDKEuv4jUlwq03JoAZY4aL551ztiXYkhU2Edga8T+LpgkbcJqCZO ntpeCT6xNug//Cvsrvz6KFzvMgkjmyLgJ4YYLzknC23MFcILZdkGe0YMiz+NGlbhQJYz lX2xNUaakFupR3Jcc9/j5S2KHy79RiQrc1tcFrtvvFeoMxgSVqMVHYmyqfWs+yoUhoKm jBT437ZGGV/FygAXdLEGx0j+5HDpoYWADnb0TawUfrPTWuX5Jye2MQMrX/jNsAc2rZ2S 3/iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3XmLumZO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020aa796e4000000b0064d3e86948esi13383779pfq.115.2023.06.16.12.37.20; Fri, 16 Jun 2023 12:37:35 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=3XmLumZO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245658AbjFPTRG (ORCPT + 99 others); Fri, 16 Jun 2023 15:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbjFPTQ4 (ORCPT ); Fri, 16 Jun 2023 15:16:56 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09EA3A8C; Fri, 16 Jun 2023 12:16:54 -0700 (PDT) Date: Fri, 16 Jun 2023 19:16:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686943013; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iovYtGDAR/iBGfQFTuKy+OfLY4uRUPtPAYOMshctPE0=; b=3XmLumZO1viAcpRF/plHjU3AZ48D02cWnL9+ZAyFMPZFdFajznmWQ3ZaJUdRQWZjmVaB7j 1Z2B+EHVHBkDGXXHWQS/p4jOsPjwWy6don6z5xgwHKs07HI/71hK9F8mdsXsA3v3/hlFur 9NvK71u9yExSJ6zwzwbQ5GwD1XEhlbst6VTqh8fsmsfuXPgI4OxV8VGdSn1WhAIyt7QWUg MmQ40gnVtUx3t3OgouwUL+5UIwK/K/1oR+SDBXKZ2/3TxuMhkaXlR5LU6rt7qTDAduG7n2 BU8WDxWRXhsExuUXG/Errym/CWFWtWcPQZRD0nbdIgvcjYGwLTkoMj2/ncCVjQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686943013; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iovYtGDAR/iBGfQFTuKy+OfLY4uRUPtPAYOMshctPE0=; b=IQDKuAPs7rL51DxhrR74FDVurV1ORXil6SD1n32qBXzeRDdzCZKjMoXJr++UNGDgqeR9Y7 OjPMcGgCpILeDmDg== From: "tip-bot2 for Rick Edgecombe" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/shstk] x86/shstk: Wire in shadow stack interface Cc: Rick Edgecombe , Dave Hansen , "Borislav Petkov (AMD)" , Kees Cook , "Mike Rapoport (IBM)" , Pengfei Xu , John Allen , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <168694301311.404.15338316204935361111.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1768889259366598993?= X-GMAIL-MSGID: =?utf-8?q?1768889259366598993?= The following commit has been merged into the x86/shstk branch of tip: Commit-ID: d463cfe241f0ea4194f3575b4d28fd744db321f1 Gitweb: https://git.kernel.org/tip/d463cfe241f0ea4194f3575b4d28fd744db321f1 Author: Rick Edgecombe AuthorDate: Mon, 12 Jun 2023 17:11:03 -07:00 Committer: Dave Hansen CommitterDate: Thu, 15 Jun 2023 16:31:34 -07:00 x86/shstk: Wire in shadow stack interface 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 Signed-off-by: Dave Hansen 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 Link: https://lore.kernel.org/all/20230613001108.3040476-38-rick.p.edgecombe%40intel.com --- 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 ea0bf11..d723cdc 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; }