From patchwork Wed Aug 2 22:19:28 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: 130192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp774697vqx; Wed, 2 Aug 2023 15:51:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHh+julxy4mZ/20VKLHp8Vt7TnSdTplklhJpXnI2/jgBREpk1T2diQjOmRu3W10Ptf4UnuR X-Received: by 2002:a5d:4443:0:b0:317:3d35:b809 with SMTP id x3-20020a5d4443000000b003173d35b809mr10454526wrr.2.1691016706843; Wed, 02 Aug 2023 15:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691016706; cv=none; d=google.com; s=arc-20160816; b=WrXJu5suSz2FEsi/0WIs/ItOEmABcn3aIjZ4ae1JXhgnF5F4f9WpHVtC1OSuuEJAXe c2/hMZ+goc3b3y/FWkBJhYbadLrRt6bsOlceYZ2akyNVbe7LAAME59Qp5taZHyDIslkS 8/Go1dp5hR0sZzcWhujGQmVtzyZrblf6xO4XjfvM15jGascVFWpC5uYUraMx6FZh4h/X 8hwFAsGtEIuVK7oL1pcqpEbPsZtj8Cdp7dofoO9AlQNCJXyYgZnt6k2mp7n7CRP5HGzu B35NTDnclcWd2sYVO5C+AKwueSkYqQAO0QSQAipOH64GQgI7daAWgUbgse8JF2Sg0If1 T2cw== 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=UPIuUeivTqjwJWivQoXOvYw2V+3/HwN/ogghC08VCps=; fh=TP5hGXUss9NVznuLhHn29IY8s2b42GYJvI6UwvTtDG8=; b=uJP/Fr3a/iQBP9LlW4986nh39TKGNUOY4wo+E2eWYXQZJLy2M29tQw/Mgq7FxHaKuH vnmza/C8iHU7sFLVdkZXDNdKBIwkLXiB9JblLrsg3eK0kW9kHXXAJtn+8UsmtW9mjG8c GYuXhZnY8Yf5yiuw5cl3VsYyR4g21UAwnUQuBrm/6s/x0A4/vYy+OFkvYqCPLI1leBJM FcLaQKvYdG5xqoapg2DEbB8IrXZepu7gwqqwB5ihmsSK8l+OjnW/I07UV8uTKD4Plqd+ z23WeoJL0flgxhdSRBOGXM+nJHGwdW2ESfX8QNAELIfZWWvmqLcRq7OgTPKJFwRsh8Ef 3fjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v6rYWsRh; dkim=neutral (no key) header.i=@linutronix.de; 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 i6-20020a1709063c4600b0098d861f6513si10857891ejg.68.2023.08.02.15.51.23; Wed, 02 Aug 2023 15:51:46 -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=v6rYWsRh; dkim=neutral (no key) header.i=@linutronix.de; 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 S233852AbjHBWTs (ORCPT + 99 others); Wed, 2 Aug 2023 18:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbjHBWTc (ORCPT ); Wed, 2 Aug 2023 18:19:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A762737; Wed, 2 Aug 2023 15:19:31 -0700 (PDT) Date: Wed, 02 Aug 2023 22:19:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691014769; 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=UPIuUeivTqjwJWivQoXOvYw2V+3/HwN/ogghC08VCps=; b=v6rYWsRhZ08iNO0paXzink0M733VYk+hs6HoTEVO+XAOuD5W2p+Hh5Tt07UUAQhypsvMrA 2H0yJ1JKqWwtYMV1C+sFZOuSUnmOv5MX+bwGKOYi2IMO46tf2Tc8f8sDYiftYuFftgPpzo s8cQne9rjEdY86JpfmQU5TcHvbmnWl9ak1JKR7BqrRx6P6KQwofHuDcS3qaW/PAgw2Ww0d 3Y6NdOBtujTyLcSQEKamlieddRoFV1I0RC3d/ufLYz4xrjQhccy7Eph4/kBiRL4IbWOyQD ZQCN6berpKMi7XdTeXrDu7rErKAgNaqRNL5jxMbdo9LLSWMhhsDokxelQiCqXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691014769; 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=UPIuUeivTqjwJWivQoXOvYw2V+3/HwN/ogghC08VCps=; b=OQWndwCRoZvj4gS3Io/HbNjxcXYX61//u9tCf0PC8uUoxkH/Cj2UaP6gzEm1nRBfR6NLsY PhMhrrycKpHEr3Cw== 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: <169101476881.28540.10108940235697972924.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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: INBOX X-GMAIL-THRID: 1773159534560135395 X-GMAIL-MSGID: 1773159534560135395 The following commit has been merged into the x86/shstk branch of tip: Commit-ID: 488af8ea7131185c1adcbb0b52da2b6800429ecb Gitweb: https://git.kernel.org/tip/488af8ea7131185c1adcbb0b52da2b6800429ecb Author: Rick Edgecombe AuthorDate: Mon, 12 Jun 2023 17:11:03 -07:00 Committer: Dave Hansen CommitterDate: Wed, 02 Aug 2023 15:01:51 -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; }