From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v2 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately Date: Fri, 17 Jun 2016 22:30:45 +0200 Message-ID: <20160617203045.GB3842@pd.tnic> References: <3336bb02792d56c49d18e2f7a435fd194a4a22e4.1466192946.git.luto@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Received: from mail.skyhub.de ([78.46.96.112]:59215 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932469AbcFQUau (ORCPT ); Fri, 17 Jun 2016 16:30:50 -0400 Content-Disposition: inline In-Reply-To: <3336bb02792d56c49d18e2f7a435fd194a4a22e4.1466192946.git.luto@kernel.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Nadav Amit , Kees Cook , Brian Gerst , "kernel-hardening@lists.openwall.com" , Linus Torvalds , Josh Poimboeuf , Jann Horn , Heiko Carstens On Fri, Jun 17, 2016 at 01:00:39PM -0700, Andy Lutomirski wrote: > It's currently only used in the EFI code, which is safe AFAICT. "It is basically useful for a pagetable hierarchy which is not init_mm." > Warn if anyone tries to use it on the normal kernel pgd. > > Signed-off-by: Andy Lutomirski > --- > arch/x86/mm/pageattr.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c > index 6a8026918bf6..e9b9c5cedbb8 100644 > --- a/arch/x86/mm/pageattr.c > +++ b/arch/x86/mm/pageattr.c > @@ -1996,6 +1996,9 @@ out: > void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address, > unsigned numpages) > { > + /* Unmapping kernel entries from init_mm's pgd is not allowed. */ > + WARN_ON(root == init_mm.pgd); We can also return and not do the unmapping: if (WARN_ON(root == init_mm.pgd)) return; -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.