From patchwork Wed Jul 19 22:47:27 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: 122895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2769895vqt; Wed, 19 Jul 2023 16:23:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHvdDeXMQU0Mxu3CgbUC0xy1a0C3DPNAZrjL9AvLbRq+8ikekx+/HQN7qW8EvFlVR66fleC X-Received: by 2002:a05:6808:b3b:b0:3a4:17cd:dd31 with SMTP id t27-20020a0568080b3b00b003a417cddd31mr3831693oij.14.1689809024371; Wed, 19 Jul 2023 16:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689809024; cv=none; d=google.com; s=arc-20160816; b=lbF4aTQ/U6/IZckGpoKGb9UhkKHIGebCLuIymJynPv3s6nKNE1U7n4paIuK17Glr9A qpqoxSyXPKYhWe6DD5vAn4uzpZiTpe2ST/kADMlHrhjh/ladXLWCFiRI7fGukerjkjy6 HyUXRCn4zY3VbaIZpRpA91rYjL/hROFPSRY6MFZT0XIqHHnWwiBgIP0td4TmDqjiJKqF LldsD9ExYaD1M2yIhHpNQmvwBX8Ww1pwiLX2ZliX2RyVaJ/6FYvTIyc1Zsek6Hu0FrS+ Uu+z2q0aCTux0LfJwb8YQioohGkf7Fs2HKd90HS/zmhEIF6Uj5Tnk9gOzMeFtCvQZxiT RgjA== 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=lvQD2v47OmpQLyD6tCUDQcGs/nfoahlZfJXIfvLLcYo=; fh=TP5hGXUss9NVznuLhHn29IY8s2b42GYJvI6UwvTtDG8=; b=Z6yMFbmm/4jqYyiFvx8XPpOZLqZfQNCzmHdHJz3J3jIr2XNSNwFYQcQN5JI5hKoWvr vthNrnKUFeuyQtGJLDgBt8Kca5eVkiC6cZ4Xdcs8LSru90zICtME1huklu+G03zqhz1+ GVEjHRo9nmAXTvshp6OQWxIKZfBIsRHgmU9xwcop6iz0kkWQK7aBMJIqABULpPir0FnC Fk1qYkGsoX1Rb/a239BmEr9C3wh0CsOk5zxSy/WbYuAskjtCfrfCLjAizKk2XODSegrV QW1sDg5FfrZ4XfSnCH5SWAIWd/uvBJn4A0V7sY8X7cnHY907Auii335uNpDyWP0SGHg0 XIIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UqvDJVJR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=u7t6VdWj; 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 a21-20020a17090a8c1500b00263f5a29bf4si2279775pjo.20.2023.07.19.16.23.29; Wed, 19 Jul 2023 16:23:44 -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=UqvDJVJR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=u7t6VdWj; 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 S230120AbjGSWrp (ORCPT + 99 others); Wed, 19 Jul 2023 18:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjGSWrb (ORCPT ); Wed, 19 Jul 2023 18:47:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE6C81FFE; Wed, 19 Jul 2023 15:47:30 -0700 (PDT) Date: Wed, 19 Jul 2023 22:47:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689806848; 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=lvQD2v47OmpQLyD6tCUDQcGs/nfoahlZfJXIfvLLcYo=; b=UqvDJVJRe5LZOSXZGm2bB8XM1Mk1rIIlyaXOhaJk7GHkbDN3tXNAPHgqAIDEQz0UeBzU5n uvJivKGrMSenYv6Tp6JublTu7yP7EOQZHrp6tM0yKFAeyKikUIILCJxU7za/vQ+UVihQmp b9aLv1NHzKqZgCeS0Zr3auDl9TjVLovt80Ede8WCyPCGiT/Plrlxp4lcI7+FcURuHciuRt Kjle8kRUpkj6L70wqCGUiwkBlG9qQtI5jy/+EgVNljxdBn57faFM1SDE/tuOQLp5ZHmkRp ygBG8v7n0F4WS1dKO7sxxy/r+SvO8qOk7LTu2g31JiyE339F7A72bbbkfmT/gg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689806848; 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=lvQD2v47OmpQLyD6tCUDQcGs/nfoahlZfJXIfvLLcYo=; b=u7t6VdWjBfSDDYL7xFkWTMamyppM0UzCasjX3eky7ygELW8Y4l3uhskFfyFdAbcr1n6W7O Vm6qBNAY1cin77CQ== 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: <168980684796.28540.5293840532791424484.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: 1771893187461684521 X-GMAIL-MSGID: 1771893187461684521 The following commit has been merged into the x86/shstk branch of tip: Commit-ID: 90359b0a7eed998740ae3794c66aac98d09d6ee1 Gitweb: https://git.kernel.org/tip/90359b0a7eed998740ae3794c66aac98d09d6ee1 Author: Rick Edgecombe AuthorDate: Mon, 12 Jun 2023 17:11:03 -07:00 Committer: Rick Edgecombe CommitterDate: Tue, 11 Jul 2023 14:13:46 -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; }