Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753343AbeAEWsU (ORCPT + 1 other); Fri, 5 Jan 2018 17:48:20 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:36746 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753308AbeAEWsR (ORCPT ); Fri, 5 Jan 2018 17:48:17 -0500 X-Google-Smtp-Source: ACJfBovSYC3R6I6ikEbhd1AUBPt/Ja6qxCcHrLu1NhzZReP0EdbLNYIGh+f9DvvSkBKrNn9ZXqAq1Yz6YKDtYCPu1pk= MIME-Version: 1.0 In-Reply-To: References: <20171123003438.48A0EEDE@viggo.jf.intel.com> <20171123003447.1DB395E3@viggo.jf.intel.com> <93776eb2-b6d4-679a-280c-8ba558a69c34@linux.intel.com> <20a54a5f-f4e5-2126-fb73-6a995d13d52d@linux.intel.com> <282e2a56-ded1-6eb9-5ecb-22858c424bd7@linux.intel.com> <868196c9-52ed-4270-968f-97b7a6784f61@linux.intel.com> From: Hugh Dickins Date: Fri, 5 Jan 2018 14:48:16 -0800 Message-ID: Subject: Re: [PATCH 05/23] x86, kaiser: unmap kernel from userspace page tables (core patch) To: Jiri Kosina Cc: Dave Hansen , Yisheng Xie , linux-kernel , linux-mm , richard.fellner@student.tugraz.at, moritz.lipp@iaik.tugraz.at, Daniel Gruss , michael.schwarz@iaik.tugraz.at, Andrew Lutomirski , Linus Torvalds , Kees Cook , x86@kernel.org, Andrea Arcangeli Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Fri, Jan 5, 2018 at 1:14 PM, Jiri Kosina wrote: > On Fri, 5 Jan 2018, Dave Hansen wrote: > >> >>> --- a/arch/x86/platform/efi/efi_64.c >> >>> +++ b/arch/x86/platform/efi/efi_64.c >> >>> @@ -95,6 +95,12 @@ pgd_t * __init efi_call_phys_prolog(void >> >>> save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE); >> >>> vaddress = (unsigned long)__va(pgd * PGDIR_SIZE); >> >>> set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress)); >> >>> + /* >> >>> + * pgprot API doesn't clear it for PGD >> >>> + * >> >>> + * Will be brought back automatically in _epilog() >> >>> + */ >> >>> + pgd_offset_k(pgd * PGDIR_SIZE)->pgd &= ~_PAGE_NX; >> >>> } >> >>> __flush_tlb_all(); >> >> >> >> Wait a sec... Where does the _PAGE_USER come from? Shouldn't we see >> >> the &init_mm in there and *not* set _PAGE_USER? >> > >> > That's because pgd_populate() uses _PAGE_TABLE and not _KERNPG_TABLE for >> > reasons that are behind me. Oh, I completely missed that; and then the issue would have got hidden by one of my later per-process-kaiser patches. >> > >> > I did put this on my TODO list, but for later. >> > >> > (and yes, I tried clearing _PAGE_USER from init_mm's PGD, and no obvious >> > breakages appeared, but I wanted to give it more thought later). >> >> Feel free to add my Ack on this. And mine - thanks a lot for dealing with this Jiri. > > Thanks. I'll extract the patch out of this thread and submit it > separately, so that it doesn't get lost buried here. > >> I'd personally much rather muck with random relatively unused bits of >> the efi code than touch the core PGD code. > > Exactly. Especially at this point. Indeed. > >> We need to go look at it again in the 4.16 timeframe, probably. > > Agreed. On my TODO list already. > > Thanks, > > -- > Jiri Kosina > SUSE Labs >