Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754051AbdLNWZA (ORCPT ); Thu, 14 Dec 2017 17:25:00 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:59468 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753301AbdLNWY7 (ORCPT ); Thu, 14 Dec 2017 17:24:59 -0500 Date: Thu, 14 Dec 2017 23:24:39 +0100 From: Peter Zijlstra To: Linus Torvalds Cc: Andy Lutomirski , "linux-kernel@vger.kernel.org" , Thomas Gleixner , X86 ML , Dave Hansen , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , "Liguori, Anthony" , Will Deacon , "linux-mm@kvack.org" , "Kirill A. Shutemov" , Dan Williams Subject: Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced Message-ID: <20171214222439.rovm3t7iaakefati@hirez.programming.kicks-ass.net> References: <20171214112726.742649793@infradead.org> <20171214113851.647809433@infradead.org> <20171214220226.GL3326@worktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: 1054 Lines: 27 On Thu, Dec 14, 2017 at 02:14:00PM -0800, Linus Torvalds wrote: > On Thu, Dec 14, 2017 at 2:02 PM, Peter Zijlstra wrote: > > > > _Should_ being the operative word, because I cannot currently see it > > DTRT. But maybe I'm missing the obvious -- I tend to do that at times. > > At least the old get_user_pages_fast() code used to check the USER bit: > > unsigned long need_pte_bits = _PAGE_PRESENT|_PAGE_USER; > > if (write) > need_pte_bits |= _PAGE_RW; > > but that may have been lost when we converted over to the generic code. The generic gup_pte_range() has pte_access_permitted() (which has the above test) in the right place. > It shouldn't actually _matter_, since we'd need to change access_ok() > anyway (and gup had better check that!) get_user_pages_fast() (both of them) do indeed test access_ok(), but the regular get_user_pages() does not, I suspect because it can operate on a foreign mm. And its the regular old get_user_pages() that's all sorts of broken wrt !PAGE_USER too.