Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2377841imm; Thu, 9 Aug 2018 11:50:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxYTLJ1F8bjx8eaf9dVOf20vCJeUuaE5Kk4XeJFw6SkTsg6/Q2FJRFNWOhJIG34GlJm+ejE X-Received: by 2002:a17:902:1081:: with SMTP id c1-v6mr3112197pla.250.1533840628032; Thu, 09 Aug 2018 11:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533840628; cv=none; d=google.com; s=arc-20160816; b=EhPDNUlb4YTPRiqwHeYFnEwCuACVH11fvNMS/DwB0i8NcQVWZhcnHVtxPSc43gfNCf 06JbXsK1YNZacYoNbDxk4pcXmmJIIOolzFSTqEiYQ92yMblO7eirjv63sOVA4wdGwxO+ jatVn194IZZk0sOXFF+SYNyDBoTJNjbCO9txGCQ5T8ww9bki3marO4CKvyMxpWLdMjFk +r5IxwWGVL4Fyf2xIC16Qs2HdcygR3jg/DwCyBAKbNIis/5Q/M0iujp8B33+MLpTJq7+ +vBHijiHPXldRCzHi2N0Dw/SseaUSHVgloxoZbP9Aen9SPu/MB0cSQNAJ0dcF6B94De3 kT7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=ciOILXxeD5EF5vuj72+xgEmm9gpy8vfVh0EekG3KW0c=; b=U/f/euFULVhZGcl0df7D93WPJxKonbx6CPPxOEM3aFtmqFw215E355jfrHCeF7Rho4 ImcfupkSuKNbdo+gBFjPKrGR3u2fWQghKlEkeYWa2dD8iRHrq2YnGbqmbikIihT3oZI8 /+aIUfAGQdAtVKH5kLGYwEPzgTBPtnemI0z19gHSbnZumMjTDEhw9g/hChqjDmNJ0TM0 HOmMTTMGzUcgijJq28UJq5P8/4hESmN8ZIHRc6n8LpUAsNjSszESIPFj5HLnAI2myHXs wok9Wj8gICXA75kh7Sy2CsK3ltD5OoDk6Fa7UWCk7wqgRvzUdtVzlaQMmIZZ4B9kFML/ 45nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23-v6si6488530pli.389.2018.08.09.11.50.13; Thu, 09 Aug 2018 11:50:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbeHIVOn (ORCPT + 99 others); Thu, 9 Aug 2018 17:14:43 -0400 Received: from terminus.zytor.com ([198.137.202.136]:34091 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbeHIVOm (ORCPT ); Thu, 9 Aug 2018 17:14:42 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w79IkULF2146770 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Aug 2018 11:46:30 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w79IkSeQ2146765; Thu, 9 Aug 2018 11:46:28 -0700 Date: Thu, 9 Aug 2018 11:46:28 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Joerg Roedel Message-ID: Cc: dhgutteridge@sympatico.ca, jkosina@suse.cz, luto@kernel.org, mingo@kernel.org, will.deacon@arm.com, jpoimboe@redhat.com, gregkh@linuxfoundation.org, llong@redhat.com, linux-kernel@vger.kernel.org, peterz@infradead.org, jroedel@suse.de, dave.hansen@intel.com, eduval@amazon.com, tglx@linutronix.de, David.Laight@aculab.com, torvalds@linux-foundation.org, pavel@ucw.cz, boris.ostrovsky@oracle.com, dvlasenk@redhat.com, bp@alien8.de, jgross@suse.com, aarcange@redhat.com, brgerst@gmail.com, hpa@zytor.com Reply-To: gregkh@linuxfoundation.org, jpoimboe@redhat.com, will.deacon@arm.com, mingo@kernel.org, jkosina@suse.cz, luto@kernel.org, dhgutteridge@sympatico.ca, dave.hansen@intel.com, jroedel@suse.de, peterz@infradead.org, linux-kernel@vger.kernel.org, llong@redhat.com, pavel@ucw.cz, David.Laight@aculab.com, torvalds@linux-foundation.org, tglx@linutronix.de, eduval@amazon.com, hpa@zytor.com, aarcange@redhat.com, brgerst@gmail.com, jgross@suse.com, bp@alien8.de, dvlasenk@redhat.com, boris.ostrovsky@oracle.com In-Reply-To: <1533727000-9172-1-git-send-email-joro@8bytes.org> References: <1533727000-9172-1-git-send-email-joro@8bytes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/mm/pti: Move user W+X check into pti_finalize() Git-Commit-ID: a13c600e15de44ccf03df28d3311ef3cb754ed9b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a13c600e15de44ccf03df28d3311ef3cb754ed9b Gitweb: https://git.kernel.org/tip/a13c600e15de44ccf03df28d3311ef3cb754ed9b Author: Joerg Roedel AuthorDate: Wed, 8 Aug 2018 13:16:40 +0200 Committer: Thomas Gleixner CommitDate: Thu, 9 Aug 2018 20:42:07 +0200 x86/mm/pti: Move user W+X check into pti_finalize() The user page-table gets the updated kernel mappings in pti_finalize(), which runs after the RO+X permissions got applied to the kernel page-table in mark_readonly(). But with CONFIG_DEBUG_WX enabled, the user page-table is already checked in mark_readonly() for insecure mappings. This causes false-positive warnings, because the user page-table did not get the updated mappings yet. Move the W+X check for the user page-table into pti_finalize() after it updated all required mappings. Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Cc: "H . Peter Anvin" Cc: linux-mm@kvack.org Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Dave Hansen Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Jiri Kosina Cc: Boris Ostrovsky Cc: Brian Gerst Cc: David Laight Cc: Denys Vlasenko Cc: Eduardo Valentin Cc: Greg KH Cc: Will Deacon Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: Andrea Arcangeli Cc: Waiman Long Cc: Pavel Machek Cc: "David H . Gutteridge" Cc: joro@8bytes.org Link: https://lkml.kernel.org/r/1533727000-9172-1-git-send-email-joro@8bytes.org --- arch/x86/include/asm/pgtable.h | 7 +++++-- arch/x86/mm/dump_pagetables.c | 3 +-- arch/x86/mm/pti.c | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index e39088cb59ab..a1cb3339da8d 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -30,11 +30,14 @@ int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user); void ptdump_walk_pgd_level_checkwx(void); +void ptdump_walk_user_pgd_level_checkwx(void); #ifdef CONFIG_DEBUG_WX -#define debug_checkwx() ptdump_walk_pgd_level_checkwx() +#define debug_checkwx() ptdump_walk_pgd_level_checkwx() +#define debug_checkwx_user() ptdump_walk_user_pgd_level_checkwx() #else -#define debug_checkwx() do { } while (0) +#define debug_checkwx() do { } while (0) +#define debug_checkwx_user() do { } while (0) #endif /* diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index ccd92c4da57c..b8ab9012ffd6 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -569,7 +569,7 @@ void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd, bool user) } EXPORT_SYMBOL_GPL(ptdump_walk_pgd_level_debugfs); -static void ptdump_walk_user_pgd_level_checkwx(void) +void ptdump_walk_user_pgd_level_checkwx(void) { #ifdef CONFIG_PAGE_TABLE_ISOLATION pgd_t *pgd = INIT_PGD; @@ -586,7 +586,6 @@ static void ptdump_walk_user_pgd_level_checkwx(void) void ptdump_walk_pgd_level_checkwx(void) { ptdump_walk_pgd_level_core(NULL, NULL, true, false); - ptdump_walk_user_pgd_level_checkwx(); } static int __init pt_dump_init(void) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 1dc5c683e7a5..d58b4aba9510 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -646,4 +646,6 @@ void pti_finalize(void) */ pti_clone_entry_text(); pti_clone_kernel_text(); + + debug_checkwx_user(); }