Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp758650rwi; Mon, 10 Oct 2022 06:56:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46pIXKF89+wFc7DiP7oCtj6R3Jvq1NbDI++E94BXr8BF8CLjLf3dA+SpLtBqFy9gnfbk0Y X-Received: by 2002:a63:187:0:b0:43b:cf3c:c64d with SMTP id 129-20020a630187000000b0043bcf3cc64dmr16734483pgb.359.1665410180161; Mon, 10 Oct 2022 06:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665410180; cv=none; d=google.com; s=arc-20160816; b=tPlPbzPkJpNibIwljinh521TXc7Duydvd0GYGNc6vcGPg2Xzpf8ltnNC/26WGB419E DikvZEpwadKtmbXyPmyrpQSrx5QaEPuCTe0oQOdK0LeQK26FF5qRgZgC0RUn9+kzXKb0 /uLq1/U64MmGiPGoz2HPMDM50GoUR1UEKRirEJSHHxicj5BogQOzWjGltBBSt0ADap1A 2kXCCvm3APNEKSaYLaMBtWhTrJ9HEcheZY6iSilTXyJA1XBQi0f6D9+U03GCWNiYk2uh aMIbB2wXZO8d3uWrMUiPRnSE/Ez4lnpRN4Hj9gj/0TN0osUP14NaRfGwi5UoF4Vfjlsf yrdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=uRewDE0rZn6hJgooSIadeEW16yLPv94UEqowboDO7Tg=; b=yH+cWaVeoFiEzMT2olekppEiHDcrkVTm7Uou9wCUVtyhLMicHxDVsw0/kg6PtRA5dZ 2RUpRtjo4weCV4dJV8xFSG9P8mzV6vWNAAlHjhVfpiVV0oOaswAq6pWqyCBb0GBWG7v9 EpYx5ZE/31o+UiFif854d//Nl1F1+VqIlwrwVd+hDYV+YuvvEsM/w1IRkSpAHXtzs7NB LJbM145ig52NWv9vdyWdUbMh3L2r3dGFUVjtEz1U/+oXL3fJsFoN0D6ScTfjQxI95Xlr f+JwXN1MbNu3AhgjBlc4L6zIM8Nljvi4UPDri9hSpLWdQ1xFYCwlxFt7tEjdg2d2Sz89 UaHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cvs8g1e+; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn5-20020a17090b38c500b00203182b9d00si19608326pjb.130.2022.10.10.06.56.07; Mon, 10 Oct 2022 06:56:20 -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=@redhat.com header.s=mimecast20190719 header.b=Cvs8g1e+; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbiJJNkp (ORCPT + 99 others); Mon, 10 Oct 2022 09:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiJJNkj (ORCPT ); Mon, 10 Oct 2022 09:40:39 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55DEF54667 for ; Mon, 10 Oct 2022 06:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665409236; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=uRewDE0rZn6hJgooSIadeEW16yLPv94UEqowboDO7Tg=; b=Cvs8g1e+2AaPLynfK/jcOx5eSdCTrBfJqAOhlkf7o2KF6GfZhOnFQsl0DwM2syquZ4X027 cw7dngx91MM7Sc0LJ430XP/Ww+LqELEhTmfg4E4MPHadlo4Rg8YP15Qhf6CSAJ2E6AyX85 56BVMsQJafdt6a6bm03kwHd2db20v6s= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-290-1jG5H1LFPHOCdfbzFg3Vtg-1; Mon, 10 Oct 2022 09:40:29 -0400 X-MC-Unique: 1jG5H1LFPHOCdfbzFg3Vtg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A3E01C05157; Mon, 10 Oct 2022 13:40:27 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2C5EC210E; Mon, 10 Oct 2022 13:40:19 +0000 (UTC) From: Florian Weimer To: Andrew Cooper Cc: Kees Cook , 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 , "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" , Yu-cheng Yu Subject: Re: [PATCH v2 18/39] mm: Add guard pages around a shadow stack. References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-19-rick.p.edgecombe@intel.com> <202210031127.C6CF796@keescook> <37ef8d93-8bd2-ae5e-4508-9be090231d06@citrix.com> <87bkqj26zp.fsf@oldenburg.str.redhat.com> <6e75eb27-c16b-ccfe-08b9-856edeff51eb@citrix.com> Date: Mon, 10 Oct 2022 15:40:18 +0200 In-Reply-To: <6e75eb27-c16b-ccfe-08b9-856edeff51eb@citrix.com> (Andrew Cooper's message of "Mon, 10 Oct 2022 13:32:51 +0000") Message-ID: <87tu4bztj1.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 * Andrew Cooper: > On 10/10/2022 13:33, Florian Weimer wrote: >> * Andrew Cooper: >> >>> You don't actually need a hole to create a guard.=C2=A0 Any mapping of = type >>> !=3D shstk will do. >>> >>> If you've got a load of threads, you can tightly pack stack / shstk / >>> stack / shstk with no holes, and they each act as each other guard page= s. >> Can userspace read the shadow stack directly? Writing is obviously >> blocked, but reading? > > Yes - regular reads are permitted to shstk memory. > > It's actually a great way to get backtraces with no extra metadata > needed. Indeed, I hope shadow stacks can be used to put the discussion around frame pointers to a rest, at least when it comes to profiling. 8-) >> POSIX does not appear to require PROT_NONE mappings >> for the stack guard region, either. However, the >> pthread_attr_setguardsize manual page pretty clearly says that it's got >> to be unreadable and unwriteable. Hence my question. > > Hmm.=C2=A0 If that's what the manuals say, then fine. > > But honestly, you don't get very far at all without faulting on a > read-only stack. I guess we can update the manual page proactively. It does look like a tempting optimization. Thanks, Florian