From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27452C433FE for ; Mon, 10 Oct 2022 13:40:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 532866B0075; Mon, 10 Oct 2022 09:40:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E2656B0078; Mon, 10 Oct 2022 09:40:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3827B8E0002; Mon, 10 Oct 2022 09:40:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 236ED6B0075 for ; Mon, 10 Oct 2022 09:40:36 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E23AA160237 for ; Mon, 10 Oct 2022 13:40:35 +0000 (UTC) X-FDA: 80005149630.20.DD772D9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 12236A0022 for ; Mon, 10 Oct 2022 13:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665409234; 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=OYlPsTshuSM346bpU1F70uOCDx8qrTrkPn96epyVt85lfHRiYAOxXnBe2KrIMWZPrJJ0A1 Sl4MLEXeJ7aLKbm7hDDL+nk7jIzzoMdq9ryG6cZ+Vknul5BVKa8u6N5QRq5q2C/drfmVzT K//UT8uDK6pRm9kvZGwl2YxoSC0MC+s= 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665409235; a=rsa-sha256; cv=none; b=SzG2fqwFAd9qHL4qW0RjVN+a8zfnWO3Hy7SacGzMONgFRzXbSStOlhNrqrrVWUqXexHLNs YZaYgJNg91tWux4btzVPtNjgHuXdwjQkChwv+xQ1nWSNEst3+TBsZCnlsYAhFJ0rShVD6J kaqU/eWVNDOWzdkJ4WKgy4GgjwVzuzE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OYlPsTsh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665409235; h=from:from:sender: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:dkim-signature; bh=uRewDE0rZn6hJgooSIadeEW16yLPv94UEqowboDO7Tg=; b=3LYOJT+btSxR7eHp0/6XrXhYCKBcU3CEuD3qyTt4dG8JZI4ylZgZXfIUaeyqpAFFaIFSjR HoZyoSjRW/T/HsKVuzEbRNfbOX4I4z8B0vqC19Eo8FqtaaBLD6vaxElP1GmGOuDyFvfxSn ruqcg8dJEYcq9N//qJJpMGVViZJz/Xk= X-Stat-Signature: nfcdhemnx11oocgay5f7tjbej17urzwg X-Rspamd-Queue-Id: 12236A0022 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OYlPsTsh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1665409234-52133 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: * 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