Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753232AbdLMOfQ (ORCPT ); Wed, 13 Dec 2017 09:35:16 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:39508 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbdLMOfP (ORCPT ); Wed, 13 Dec 2017 09:35:15 -0500 Date: Wed, 13 Dec 2017 15:34:55 +0100 From: Peter Zijlstra To: "Kirill A. Shutemov" Cc: Dave Hansen , Andy Lutomirski , Thomas Gleixner , LKML , X86 ML , Linus Torvalds , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , "linux-mm@kvack.org" , kirill.shutemov@linux.intel.com, aneesh.kumar@linux.vnet.ibm.com Subject: Re: [patch 05/16] mm: Allow special mappings with user access cleared Message-ID: <20171213143455.oqigy6m53qhuu7k4@hirez.programming.kicks-ass.net> References: <20171212173221.496222173@linutronix.de> <20171212173333.669577588@linutronix.de> <20171213122211.bxcb7xjdwla2bqol@hirez.programming.kicks-ass.net> <20171213125739.fllckbl3o4nonmpx@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171213125739.fllckbl3o4nonmpx@node.shutemov.name> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 954 Lines: 29 On Wed, Dec 13, 2017 at 03:57:40PM +0300, Kirill A. Shutemov wrote: > On Wed, Dec 13, 2017 at 01:22:11PM +0100, Peter Zijlstra wrote: > > get_user_pages_fast() will ultimately end up doing > > pte_access_permitted() before getting the page, follow_page OTOH does > > not do this, which makes for a curious difference between the two. > > > > So I'm thinking we want the below irrespective of the VM_NOUSER patch, > > but with VM_NOUSER it would mean write(2) will no longer be able to > > access the page. > > Oh.. > > We do call pte_access_permitted(), but only for write access. > See can_follow_write_pte(). My can_follow_write_pte() looks like: static inline bool can_follow_write_pte(pte_t pte, unsigned int flags) { return pte_write(pte) || ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte)); } am I perchance looking at the wrong tee? > The issue seems bigger: we also need such calls for other page table levels :-/ Sure.