Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp720956rwb; Tue, 4 Oct 2022 09:42:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57VhydbcY1rgd5twxpe1C8qosSylUJeEcNOetlBQbF1EOgagDAha31gVMcMSDUXTyUYZxe X-Received: by 2002:a05:6402:1bc4:b0:458:ff47:3cd5 with SMTP id ch4-20020a0564021bc400b00458ff473cd5mr9699301edb.402.1664901753181; Tue, 04 Oct 2022 09:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664901753; cv=none; d=google.com; s=arc-20160816; b=DiW465sInM447+S5AAmG0vxuxEqAuMR3qSzKfm702KNYrMdmr0mS2/5IBoKwtTHM2K eIIIIMkawGSZvDdaKfGQIZwa+o69Ay9dEQWmVYN5nI3q3ItzPubvXOG0WhCWO/aRBjkv yNi+s2IAAOclHwJntt/AvLUSxeOdCkT7cEWdjV4kIO2Cef+MyyuODJ3B6ht1RdSNS+Ax +L0zeHF7kajk3txhVIrpsljVdVlkc6Mszwll9xUcpV/KuokniGZaKpb6JpjIwSGglvKJ BaDy+aUQEHZ/fzCtwuapa+VT/B3BNOOdZmp5XAsrL29FW/nCwpu1EoIXvcHcbCZCHGuo MWlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uZMEXzCzl4xFrMUzUKUVVI4irf6qXIjvMyAzTaUK90Q=; b=Mt4Ag60GlkgWSbqf13Vf70a+jjEYxsmDofD2VH9gOPgDG3GOLFsFbiCUCgNeoWjFv9 6EDOMoxL1FqY2hyQ1qPL+bvBhHmw1du91jmcGsjKCv3uw5y+uWR++jqrYu2w2IP7N1WW RQRQANxA+sUY4XehJ05Bc3PqDr5oR9fmTj/HM6TQbEi2jMVIRsWk60wEXdaKH/9Gu07T 6vAUDtGfBYTjp6IO0zgtEQeLwGrCOnNu5Je6VrIDvs1UiqxBD/fn8umFOZluFcg5/FG9 nIdUSl9DPKJCSvNHJnYP7bCSFlqSrDugL0eROwddDx/7PFyVySw2tKpJZqzce+GwH6yh Y0Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ooJkMsJB; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a1709062ec500b00781c229eee4si9688098eji.936.2022.10.04.09.42.07; Tue, 04 Oct 2022 09:42:33 -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=@kernel.org header.s=k20201202 header.b=ooJkMsJB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbiJDPrd (ORCPT + 99 others); Tue, 4 Oct 2022 11:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiJDPr3 (ORCPT ); Tue, 4 Oct 2022 11:47:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC5F5F7D3; Tue, 4 Oct 2022 08:47:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 05BD1614C2; Tue, 4 Oct 2022 15:47:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AB8AC433D6; Tue, 4 Oct 2022 15:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664898446; bh=CPcAiHKHpUkWh0PA+NRCcRCL9rFyUZMmHsEQuOiHE3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ooJkMsJBnKsRzCfdUKKCH3gK1tBl1/nF7T2XOhJKnC4ezZGZmGoS3sTNk77qyCkzz k4JvcUGlBOJOc3X1dhRQI0C0KJuXvkYfllhSSfz3nrFmw3PchRM7W1H4hhhOFJce7I ymHHeI9A637+AhHolx5ULHoKid+MvM9mM2XqzO6yPXFRenTjOgd2yaIjV0fbqwDenY nBWshZEpTGixEcSd+kHKs/pKXyLi77MWBkd/vuGCU8BlEaI4OtYUtyjI7m7OGQZ2WH bjf14qcjOmH6Qa0oUnFOnwEuAnRQt0HM76OTwmO49kCtO3gyXLDbIQnnMS5jAoHC4d Y1mjvrr9mXNnA== Date: Tue, 4 Oct 2022 08:47:22 -0700 From: Nathan Chancellor To: Kees Cook Cc: Dave Hansen , "Gustavo A. R. Silva" , Nick Desaulniers , Rick Edgecombe , 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 , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, Tom Lendacky , "Moger, Babu" Subject: Re: [PATCH v2 33/39] x86/cpufeatures: Limit shadow stack to Intel CPUs Message-ID: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-34-rick.p.edgecombe@intel.com> <202210031656.23FAA3195@keescook> <559f937f-cab4-d408-6d95-fc85b4809aa9@intel.com> <202210032147.ED1310CEA8@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202210032147.ED1310CEA8@keescook> 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_PASS 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 Hi Kees, On Mon, Oct 03, 2022 at 09:54:26PM -0700, Kees Cook wrote: > On Mon, Oct 03, 2022 at 05:09:04PM -0700, Dave Hansen wrote: > > On 10/3/22 16:57, Kees Cook wrote: > > > On Thu, Sep 29, 2022 at 03:29:30PM -0700, Rick Edgecombe wrote: > > >> Shadow stack is supported on newer AMD processors, but the kernel > > >> implementation has not been tested on them. Prevent basic issues from > > >> showing up for normal users by disabling shadow stack on all CPUs except > > >> Intel until it has been tested. At which point the limitation should be > > >> removed. > > >> > > >> Signed-off-by: Rick Edgecombe > > > So running the selftests on an AMD system is sufficient to drop this > > > patch? > > > > Yes, that's enough. > > > > I _thought_ the AMD folks provided some tested-by's at some point in the > > past. But, maybe I'm confusing this for one of the other shared > > features. Either way, I'm sure no tested-by's were dropped on purpose. > > > > I'm sure Rick is eager to trim down his series and this would be a great > > patch to drop. Does anyone want to make that easy for Rick? > > > > > > Hey Gustavo, Nathan, or Nick! I know y'all have some fancy AMD testing > rigs. Got a moment to spin up this series and run the selftests? :) I do have access to a system with an EPYC 7513, which does have Shadow Stack support (I can see 'shstk' in the "Flags" section of lscpu with this series). As far as I understand it, AMD only added Shadow Stack with Zen 3; my regular AMD test system is Zen 2 (probably should look at procurring a Zen 3 or Zen 4 one at some point). I applied this series on top of 6.0 and reverted this change then booted it on that system. After building the selftest (which did require 'make headers_install' and a small addition to make it build beyond that, see below), I ran it and this was the result. I am not sure if that is expected or not but the other results seem promising for dropping this patch. $ ./test_shadow_stack_64 [INFO] new_ssp = 7f8a36c9fff8, *new_ssp = 7f8a36ca0001 [INFO] changing ssp from 7f8a374a0ff0 to 7f8a36c9fff8 [INFO] ssp is now 7f8a36ca0000 [OK] Shadow stack pivot [OK] Shadow stack faults [INFO] Corrupting shadow stack [INFO] Generated shadow stack violation successfully [OK] Shadow stack violation test [INFO] Gup read -> shstk access success [INFO] Gup write -> shstk access success [INFO] Violation from normal write [INFO] Gup read -> write access success [INFO] Violation from normal write [INFO] Gup write -> write access success [INFO] Cow gup write -> write access success [OK] Shadow gup test [INFO] Violation from shstk access [OK] mprotect() test [OK] Userfaultfd test [FAIL] Alt shadow stack test $ echo $? 1 I am happy to provide any information that would be useful for exploring this failure and test further iterations of this series as necessary. Cheers, Nathan test_shadow_stack.c: In function ‘create_shstk’: test_shadow_stack.c:86:70: error: ‘SHADOW_STACK_SET_TOKEN’ undeclared (first use in this function) 86 | return (void *)syscall(__NR_map_shadow_stack, addr, SS_SIZE, SHADOW_STACK_SET_TOKEN); | ^~~~~~~~~~~~~~~~~~~~~~ test_shadow_stack.c:86:70: note: each undeclared identifier is reported only once for each function it appears in test_shadow_stack.c:87:1: warning: control reaches end of non-void function [-Wreturn-type] 87 | } | ^ diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c index 22b856de5cdd..958dbb248518 100644 --- a/tools/testing/selftests/x86/test_shadow_stack.c +++ b/tools/testing/selftests/x86/test_shadow_stack.c @@ -11,6 +11,7 @@ #define _GNU_SOURCE #include +#include #include #include #include