Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5451485imm; Tue, 16 Oct 2018 10:25:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV61F7Pn9ZyznE0d+WizkP7YkvGKHEug17Sj0nbCtl8TI/RrCP+4E/9ueb6wBAotpseyrjtEO X-Received: by 2002:a63:a047:: with SMTP id u7-v6mr21135259pgn.145.1539710707537; Tue, 16 Oct 2018 10:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710707; cv=none; d=google.com; s=arc-20160816; b=O+OYsQJ2OXClcXFRMDnqQN3Vi7Gj0j3S/cOC13dXPGiez8y7wbzYnn2UryIE2wSoRl RZ6FzxswBz7Bs/LV3NeOjQ54szswN/Kd8wxV4Ehjrps1F6pF84caARxOjvIsynzXKJ65 IxRzGJgxKFeVkMH6B8Gzht+qkQeRHdgli+68crbXQDG/UhdRecugRQ9Vu9dIQRCeuMi5 tAL7yUxDGTrbh/XNU7FzchI93GGHGHxC8Li0QgvEorRCiLQmhbNZ17+X7DHA4ZJ6UlUf AM7BDVQ/qa7eyx0JKMKuKe7LuIHBoVOVEdOeOwZDb5K/5ltnt2VLva1Ro5jVO7Y6lTiy Ncxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZUI89foAvztiblJ8YDckywz+yES7v/qoaPKFID9HsB8=; b=sWuP7zfsjoKhK/ATXyBfJpe6pc7kFu9bqx27rolaXD96pab9r+PbC2SUTu+k3X874V WSIXWF2tDvlsuyn9PewNh3wnSOA7+A1I8T0SrTNzK9jXs2BiOsGjXCeIk3NJhGJy+OyY EXsznA/cO1ouyod7qXbyXAACFQMj7f0tVo1VXkiK+6RMGp2EgTW+9dJB5jDGjCalT5Sf 2F/4zF/8XKp5+qCTiKryQ1IDll0hUbAMijeykdNsFkLoMJpaWm9yEG7UyDQhmpKZu+wN 2vHZuZDK4PL0jed5orVXa9164ARHMiTqgeL9dIE+LvuNpNyZhljyjTUScfVfPEN+YumB Cwug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=erMa2KqP; 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 c89-v6si15169272pfe.60.2018.10.16.10.24.52; Tue, 16 Oct 2018 10:25:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=erMa2KqP; 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 S1731313AbeJQBOf (ORCPT + 99 others); Tue, 16 Oct 2018 21:14:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:32998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbeJQBOf (ORCPT ); Tue, 16 Oct 2018 21:14:35 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B14F12098A; Tue, 16 Oct 2018 17:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710589; bh=cwsYEq8Fs8uPL+yD3hLe71xsMjx5Evw7jjhVdwt8RyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=erMa2KqPCugV7cjI3yXMs13Wdl+iYy5fg2+Rf/SFa8yQSjksnbAcgCqQr0BEKyv/f bBVqezu/nw5K1ND9OkSInGrwMeK0KduGBO9aL203mCGohOrgcUz46EM6CsLdCImqk1 c3aUf6rV3UaXWQnZkwEzvQu3iX/oWsqfTwZ5HTqk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Michal Hocko , Johannes Thumshirn , Dan Williams Subject: [PATCH 4.9 19/71] mm: Preserve _PAGE_DEVMAP across mprotect() calls Date: Tue, 16 Oct 2018 19:09:16 +0200 Message-Id: <20181016170540.351359047@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit 4628a64591e6cee181237060961e98c615c33966 upstream. Currently _PAGE_DEVMAP bit is not preserved in mprotect(2) calls. As a result we will see warnings such as: BUG: Bad page map in process JobWrk0013 pte:800001803875ea25 pmd:7624381067 addr:00007f0930720000 vm_flags:280000f9 anon_vma: (null) mapping:ffff97f2384056f0 index:0 file:457-000000fe00000030-00000009-000000ca-00000001_2001.fileblock fault:xfs_filemap_fault [xfs] mmap:xfs_file_mmap [xfs] readpage: (null) CPU: 3 PID: 15848 Comm: JobWrk0013 Tainted: G W 4.12.14-2.g7573215-default #1 SLE12-SP4 (unreleased) Hardware name: Intel Corporation S2600WFD/S2600WFD, BIOS SE5C620.86B.01.00.0833.051120182255 05/11/2018 Call Trace: dump_stack+0x5a/0x75 print_bad_pte+0x217/0x2c0 ? enqueue_task_fair+0x76/0x9f0 _vm_normal_page+0xe5/0x100 zap_pte_range+0x148/0x740 unmap_page_range+0x39a/0x4b0 unmap_vmas+0x42/0x90 unmap_region+0x99/0xf0 ? vma_gap_callbacks_rotate+0x1a/0x20 do_munmap+0x255/0x3a0 vm_munmap+0x54/0x80 SyS_munmap+0x1d/0x30 do_syscall_64+0x74/0x150 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 ... when mprotect(2) gets used on DAX mappings. Also there is a wide variety of other failures that can result from the missing _PAGE_DEVMAP flag when the area gets used by get_user_pages() later. Fix the problem by including _PAGE_DEVMAP in a set of flags that get preserved by mprotect(2). Fixes: 69660fd797c3 ("x86, mm: introduce _PAGE_DEVMAP") Fixes: ebd31197931d ("powerpc/mm: Add devmap support for ppc64") Cc: Signed-off-by: Jan Kara Acked-by: Michal Hocko Reviewed-by: Johannes Thumshirn Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/book3s/64/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable_types.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -53,7 +53,7 @@ */ #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ _PAGE_ACCESSED | H_PAGE_THP_HUGE | _PAGE_PTE | \ - _PAGE_SOFT_DIRTY) + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP) /* * user access blocked by key */ @@ -71,7 +71,7 @@ */ #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ _PAGE_ACCESSED | _PAGE_SPECIAL | _PAGE_PTE | \ - _PAGE_SOFT_DIRTY) + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP) /* * Mask of bits returned by pte_pgprot() */ --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -134,7 +134,7 @@ */ #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \ _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \ - _PAGE_SOFT_DIRTY) + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP) #define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE) /* The ASID is the lower 12 bits of CR3 */