Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp846287rwi; Fri, 14 Oct 2022 09:16:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jb8lbT/dR6xTLAxibVMkhqsJ+taQDBQHNhqu5K8UAGKWSg7OrDN2Rb+aRJxttbCvqLgY6 X-Received: by 2002:aa7:d984:0:b0:459:168b:db91 with SMTP id u4-20020aa7d984000000b00459168bdb91mr4997528eds.92.1665764206092; Fri, 14 Oct 2022 09:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665764206; cv=none; d=google.com; s=arc-20160816; b=PXGP4yGfna/31bWaJJFE1jHlK14ByS3fYMu4rnpitSHsSKpZoqIuer3vMChfEZCDMi si+4Nm610qRbl80asa/QxrTvCCcEOFEgcEwCPoe8mkhN/6CUxcnrkzgDFy/hhsNxkiGv OT/lG1+Thru2aUYRBCKE29oHAnkf//Ejj9zqtPJwh8eRGxf1NsWL8mpixndLp1xd4p0o dCsg/dkCwSehwGtPTbheogHWJ8Nsz1xfnzRruOjQbvPaH/TbRq742iJwNvwnJUZJRoX2 v6DetPE2kT39ZZ72g3B7D4ytXT/Mh1BXtOSnN8ppJu+o4XIaKv/4CeRLFi+4ek4J4VKU yIKQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uURYEhJNF/y4ef2ytvd2xFiDhwfWuIdCXYX1RDrMcEU=; b=n+N00rU/SAue4tyiGP5U9oL/WLb+lw6jV5NWD1f8FiSFHnPUB/uX4x9zuYk7xv1FQj UFq037+AbzGQZW6F7oC8TTobIwIn3IZI7JqqzAkyh21fQDhbXg5hlkT2/ifHeMkhgX1F pnEPUmU76uGA4lOU3B3qrTumBUBL9tNYgxSa30663z7AWQu9wKYVfPnAl8Owbh4kEAOd 05hEUYdhTO5aDDuMSQLH9ip8CjA4lrR0BkNmeBrvxozLoe2tQwCO0JZyRxmFYUCYAk3X x1eDUEINKfxQBOUimGgCXRHF4FdQKOEMyLeNBxSUQslo8AJ+d5nz3EB0r8T2JvT+ikml MmoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FI8zrVaV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rl21-20020a170907217500b00779a07b4e90si2164405ejb.711.2022.10.14.09.16.12; Fri, 14 Oct 2022 09:16:46 -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=@infradead.org header.s=casper.20170209 header.b=FI8zrVaV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbiJNPwv (ORCPT + 99 others); Fri, 14 Oct 2022 11:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbiJNPwu (ORCPT ); Fri, 14 Oct 2022 11:52:50 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB671C77CC; Fri, 14 Oct 2022 08:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=uURYEhJNF/y4ef2ytvd2xFiDhwfWuIdCXYX1RDrMcEU=; b=FI8zrVaVC/8UN/s+IiozYmQHKy Y557SBFHLKXCkrCnS2qkGQO6WBcuTY9UCgzKthC5OYmAmaNRDidzUfdySBCzwEmZak48g63V7W0se harj0CbOOajx4M9COGuuEFZB31SGwzSyEhtOzDzwtY/UdMeFeYkVkbJUgsabjCu3o8WnPFWYW7VJX yhyvlOKxkjg0twaCH2fp4fjBU+DMUPJ3kNPjuOsacZZWAZ+xrgJ9JXv7/akKIdWxrls5DXgfpU87E eQT1cZyX4+yNpZBCtP+moPbnXDOYLTwpdr6p37FiH/BfjURSfu6BObNi1jef0hOl3BRHNT5bYE6+j +NS805UA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojMys-007jm1-O0; Fri, 14 Oct 2022 15:52:14 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7E68A30008D; Fri, 14 Oct 2022 17:52:08 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 67EF92C1B1259; Fri, 14 Oct 2022 17:52:08 +0200 (CEST) Date: Fri, 14 Oct 2022 17:52:08 +0200 From: Peter Zijlstra To: Rick Edgecombe Cc: 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 , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , 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 17/39] mm: Fixup places that call pte_mkwrite() directly Message-ID: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-18-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929222936.14584-18-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 On Thu, Sep 29, 2022 at 03:29:14PM -0700, Rick Edgecombe wrote: > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > index 7327b2573f7c..b49372c7de41 100644 > --- a/mm/userfaultfd.c > +++ b/mm/userfaultfd.c > @@ -63,6 +63,7 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > int ret; > pte_t _dst_pte, *dst_pte; > bool writable = dst_vma->vm_flags & VM_WRITE; > + bool shstk = dst_vma->vm_flags & VM_SHADOW_STACK; > bool vm_shared = dst_vma->vm_flags & VM_SHARED; > bool page_in_cache = page->mapping; > spinlock_t *ptl; > @@ -83,9 +84,12 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > writable = false; > } > > - if (writable) > - _dst_pte = pte_mkwrite(_dst_pte); > - else > + if (writable) { > + if (shstk) > + _dst_pte = pte_mkwrite_shstk(_dst_pte); > + else > + _dst_pte = pte_mkwrite(_dst_pte); > + } else > /* > * We need this to make sure write bit removed; as mk_pte() > * could return a pte with write bit set. Urgh.. that's unfortunate. But yeah, I don't see a way to make that pretty either.