]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.135/mm-preserve-_page_devmap-across-mprotect-calls.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.135 / mm-preserve-_page_devmap-across-mprotect-calls.patch
1 From 4628a64591e6cee181237060961e98c615c33966 Mon Sep 17 00:00:00 2001
2 From: Jan Kara <jack@suse.cz>
3 Date: Tue, 9 Oct 2018 12:19:17 +0200
4 Subject: mm: Preserve _PAGE_DEVMAP across mprotect() calls
5
6 From: Jan Kara <jack@suse.cz>
7
8 commit 4628a64591e6cee181237060961e98c615c33966 upstream.
9
10 Currently _PAGE_DEVMAP bit is not preserved in mprotect(2) calls. As a
11 result we will see warnings such as:
12
13 BUG: Bad page map in process JobWrk0013 pte:800001803875ea25 pmd:7624381067
14 addr:00007f0930720000 vm_flags:280000f9 anon_vma: (null) mapping:ffff97f2384056f0 index:0
15 file:457-000000fe00000030-00000009-000000ca-00000001_2001.fileblock fault:xfs_filemap_fault [xfs] mmap:xfs_file_mmap [xfs] readpage: (null)
16 CPU: 3 PID: 15848 Comm: JobWrk0013 Tainted: G W 4.12.14-2.g7573215-default #1 SLE12-SP4 (unreleased)
17 Hardware name: Intel Corporation S2600WFD/S2600WFD, BIOS SE5C620.86B.01.00.0833.051120182255 05/11/2018
18 Call Trace:
19 dump_stack+0x5a/0x75
20 print_bad_pte+0x217/0x2c0
21 ? enqueue_task_fair+0x76/0x9f0
22 _vm_normal_page+0xe5/0x100
23 zap_pte_range+0x148/0x740
24 unmap_page_range+0x39a/0x4b0
25 unmap_vmas+0x42/0x90
26 unmap_region+0x99/0xf0
27 ? vma_gap_callbacks_rotate+0x1a/0x20
28 do_munmap+0x255/0x3a0
29 vm_munmap+0x54/0x80
30 SyS_munmap+0x1d/0x30
31 do_syscall_64+0x74/0x150
32 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
33 ...
34
35 when mprotect(2) gets used on DAX mappings. Also there is a wide variety
36 of other failures that can result from the missing _PAGE_DEVMAP flag
37 when the area gets used by get_user_pages() later.
38
39 Fix the problem by including _PAGE_DEVMAP in a set of flags that get
40 preserved by mprotect(2).
41
42 Fixes: 69660fd797c3 ("x86, mm: introduce _PAGE_DEVMAP")
43 Fixes: ebd31197931d ("powerpc/mm: Add devmap support for ppc64")
44 Cc: <stable@vger.kernel.org>
45 Signed-off-by: Jan Kara <jack@suse.cz>
46 Acked-by: Michal Hocko <mhocko@suse.com>
47 Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
48 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
49 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
50
51 ---
52 arch/x86/include/asm/pgtable_types.h | 2 +-
53 1 file changed, 1 insertion(+), 1 deletion(-)
54
55 --- a/arch/x86/include/asm/pgtable_types.h
56 +++ b/arch/x86/include/asm/pgtable_types.h
57 @@ -134,7 +134,7 @@
58 */
59 #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \
60 _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \
61 - _PAGE_SOFT_DIRTY)
62 + _PAGE_SOFT_DIRTY | _PAGE_DEVMAP)
63 #define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE)
64
65 /* The ASID is the lower 12 bits of CR3 */