Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753960AbdLNWLJ (ORCPT ); Thu, 14 Dec 2017 17:11:09 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40984 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbdLNWLH (ORCPT ); Thu, 14 Dec 2017 17:11:07 -0500 X-Google-Smtp-Source: ACJfBost+x8FOp9L101/ydErgRwIHZkSlBk0sllk2cHPe0Rg7P+0cYmdQdf+FWiQmWWaeWFc3xVrZQ== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced From: Andy Lutomirski X-Mailer: iPhone Mail (15C114) In-Reply-To: Date: Thu, 14 Dec 2017 14:11:03 -0800 Cc: Andy Lutomirski , Peter Zijlstra , "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 Message-Id: References: <20171214112726.742649793@infradead.org> <20171214113851.647809433@infradead.org> To: Linus Torvalds Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vBEMBFcW027297 Content-Length: 1249 Lines: 23 > On Dec 14, 2017, at 1:48 PM, Linus Torvalds wrote: > > On Thu, Dec 14, 2017 at 1:44 PM, Linus Torvalds > wrote: >> >> So it clearly needs to have the PAGE_USER bit clear (to avoid users >> accessing it directly), and it needs to be marked somehow for >> get_user_pages() to refuse it too, and access_ok() needs to fail it so >> that we can't do get_user/put_user on it. > > Actually, just clearing PAGE_USER should make gup avoid it automatically. > > So really the only other thing it needs is to have access_ok() avoid > it so that the kernel can't be fooled into accessing it for the user. > > That does probably mean having to put it at the top of the user > address space and playing games with user_addr_max(). Which is not > wonderful, but certainly not rocket surgery either. That seems to rather defeat the point of using a VMA, though. And it means we still have to do a full cmp instead of just checking a sign bit in access_ok if we ever manage to kill set_fs(). Again, I have an apparently fully functional patch to alias the LDT at a high (kernel) address where we can cleanly map it in the user pagetables without any of this VMA stuff. It's much less code.