Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch)

From: Andy Lutomirski
Date: Sun Nov 26 2017 - 11:29:39 EST


On Sun, Nov 26, 2017 at 8:24 AM, Dave Hansen
<dave.hansen@xxxxxxxxxxxxxxx> wrote:
> On 11/26/2017 08:10 AM, Andy Lutomirski wrote:
>>> As a side benefit, this shouldn't have magical interactions with the
>>> vsyscall page any more.
>>>
>>> Are there cases that this would get wrong?
>>>
>> Quick ping: did this get lost?
>
> It does drop a warning that the other version of the code has, but
> that's pretty minor.
>
> Basically, we need two checks:
>
> pgd_userspace_access() (aka _PAGE_USER) and
> pgdp_maps_userspace()
>
> The original code does pgd_userspace_access() in a top-level if and then
> the pgdp_maps_userspace() checks at the second level. I think you are
> basically suggesting that we flip that.
>
> Logically, I'm sure we can make it work. It's just a matter of needing
> to look at other things first.
>
> BTW, this comment is, I think incorrect:
>
>> if (pgdp_maps_userspace(pgdp)) {
> ...
>> } else {
>> /*
>> * We can get here due to vmalloc, a vmalloc fault, memory
>> hot-add, or initial setup
>> * of kernelmode page tables. Regardless of which particular code
>> path we're in,
>> * these mappings should not be automatically propagated to the
>> usermode tables.
>> */
>
> Since we pre-populated the entire kernel area's PGDs, I don't think
> we'll ever have a valid reason to be doing a set_pgd() again on the
> kernel area.

Right, forgot about that. So it's just initial setup, then.