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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 075ADC43217 for ; Tue, 15 Nov 2022 21:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232569AbiKOVI6 (ORCPT ); Tue, 15 Nov 2022 16:08:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbiKOVI4 (ORCPT ); Tue, 15 Nov 2022 16:08:56 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FAD12D3D; Tue, 15 Nov 2022 13:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6xS2jzo+Wah9lxr2NfS/UZ9644G1gA/sqmdSnvREVHs=; b=EiNB1tnkdXXLjgnA4O8/EMHqKc 9FCIhHO3JxuJspTSZrpN1+LzvlyOODa+K933+ciiSUA4mJC1+5eYBU2xCXXes8hAOkFyfDz6CRYhp TClH0deL8UGOrL+njUyaiNfk3BlssJl6eBGe1h51BxVX8wfh/Tv+pXZxTEO9RgTEXOA9uarn6RjTW zLWEXyu+kMlx1Vm/QVoKE+pTMV6EkElmvUv66cSQKdnEXe+PgYc9FS9tNKJYh998x4OsLFeVQ5BR6 9FGjI0hI8JaKo486HpH9TFSI008U7pxXNIJwJWZ+Vz5qTAitgmZWdGNbp7SktYl0ZtQlnZXLPpM/D 9bJffGTg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov39w-0016bM-2x; Tue, 15 Nov 2022 21:07:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C26653001FD; Tue, 15 Nov 2022 22:07:54 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A7F06201646D4; Tue, 15 Nov 2022 22:07:54 +0100 (CET) Date: Tue, 15 Nov 2022 22:07:54 +0100 From: Peter Zijlstra To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "bp@alien8.de" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "pavel@ucw.cz" , "arnd@arndb.de" , "tglx@linutronix.de" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "jamorris@linux.microsoft.com" , "john.allen@amd.com" , "rppt@kernel.org" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3 15/37] x86/mm: Check Shadow Stack page fault errors Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-16-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 15, 2022 at 08:03:06PM +0000, Edgecombe, Rick P wrote: > That's right. I think the assumption that needs to be broken in the > readers head is that you can satisfy a read fault with read-only PTE. > This is kind of baked in all over the place with the zero-pfn, COW, > etc. Maybe I should try to start with that. Maybe something like: CoW -- pte_wrprotect() -- changes a SS page 'Write=0,Dirty=1' to 'Write=0,Dirty=0,CoW=1' which is a 'regular' RO page. A SS read from RET will #PF because it expects a SS page. Make sure to break the CoW so it can be restored to an SS page, as such force the write path and tickle pte_mkwrite().