Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
On Thu, Dec 14, 2017 at 2:24 PM, Peter Zijlstra wrote: > > 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. That sounds wrong. We actually had some very serious reasons why get_user_p

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
On Thu, Dec 14, 2017 at 2:23 PM, Thomas Gleixner wrote: > > The user knows the LDT contents because he put it there and it can be read > via modify_ldt(0, ) anyway. Or am I misunderstanding what you are trying to > say? I don't think they are secret, it's more of a "if they can read it, they can

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Andy Lutomirski
> On Dec 14, 2017, at 2:15 PM, Linus Torvalds > wrote: > >> On Thu, Dec 14, 2017 at 2:11 PM, Andy Lutomirski wrote: >> >> That seems to rather defeat the point of using a VMA, though. > > There never was any point in using a VMA per se. > > The point was always to just map the damn thing i

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Peter Zijlstra
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

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Thomas Gleixner
On Thu, 14 Dec 2017, Linus Torvalds wrote: > On Thu, Dec 14, 2017 at 1:22 PM, Andy Lutomirski wrote: > > > > Which kind of kills the whole thing. There's no way the idea of > > putting the LDT in a VMA is okay if it's RW. > > Sure there is. > > I really don't understand why you guys think it h

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
On Thu, Dec 14, 2017 at 2:11 PM, Andy Lutomirski wrote: > > That seems to rather defeat the point of using a VMA, though. There never was any point in using a VMA per se. The point was always to just map the damn thing in the user page tables, wasn't it? The vma bit was just an implementation d

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
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 n

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Andy Lutomirski
> 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,

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Peter Zijlstra
On Thu, Dec 14, 2017 at 01:48:50PM -0800, Linus Torvalds wrote: > Actually, just clearing PAGE_USER should make gup avoid it automatically. _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. We don't appear t

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
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_us

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
On Thu, Dec 14, 2017 at 1:22 PM, Andy Lutomirski wrote: > > Which kind of kills the whole thing. There's no way the idea of > putting the LDT in a VMA is okay if it's RW. Sure there is. I really don't understand why you guys think it has to be RO. All it has to be is not _user_ accessible. And

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Andy Lutomirski
On Thu, Dec 14, 2017 at 11:43 AM, Linus Torvalds wrote: > On Thu, Dec 14, 2017 at 8:20 AM, Andy Lutomirski wrote: >> >> If this turns out to need reverting because it breaks Wine or >> something, we're really going to regret it. > > I really don't see that as very likely. We already play other (m

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Linus Torvalds
On Thu, Dec 14, 2017 at 8:20 AM, Andy Lutomirski wrote: > > If this turns out to need reverting because it breaks Wine or > something, we're really going to regret it. I really don't see that as very likely. We already play other (much more fundamental) games with segments. But I do agree that i

Re: [PATCH v2 11/17] selftests/x86/ldt_gdt: Prepare for access bit forced

2017-12-14 Thread Andy Lutomirski
On Thu, Dec 14, 2017 at 3:27 AM, Peter Zijlstra wrote: > From: Thomas Gleixner > > In order to make the LDT mapping RO the access bit needs to be forced by > the kernel. Adjust the test case so it handles that gracefully. If this turns out to need reverting because it breaks Wine or something, w