Patch "mm: fix device-dax pud write-faults triggered by get_user_pages()" has been added to the 4.14-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
mm: fix device-dax pud write-faults triggered by get_user_pages()
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-fix-device-dax-pud-write-faults-triggered-by-get_user_pages.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
1501899a898dfb5477c55534bdfd734c046da06dMon Sep 17 00:00:00 2001
From: Dan Williams <[email protected]>
Date: Wed, 29 Nov 2017 16:10:06 -0800
Subject: mm: fix device-dax pud write-faults triggered by get_user_pages()
From: Dan Williams <[email protected]>
commit 1501899a898dfb5477c55534bdfd734c046da06d upstream.
Currently only get_user_pages_fast() can safely handle the writable gup case due to its use of pud_access_permitted() to check whether the pud entry is writable. In the gup slow path pud_write() is used instead of pud_access_permitted() and to date it has been unimplemented, just calls BUG_ON().
kernel BUG at ./include/linux/hugetlb.h:244!
[..]
RIP: 0010:follow_devmap_pud+0x482/0x490
[..]
Call Trace:
follow_page_mask+0x28c/0x6e0
__get_user_pages+0xe4/0x6c0
get_user_pages_unlocked+0x130/0x1b0
get_user_pages_fast+0x89/0xb0
iov_iter_get_pages_alloc+0x114/0x4a0
nfs_direct_read_schedule_iovec+0xd2/0x350
? nfs_start_io_direct+0x63/0x70
nfs_file_direct_read+0x1e0/0x250
nfs_file_read+0x90/0xc0For now this just implements a simple check for the _PAGE_RW bit similar to pmd_write. However, this implies that the gup-slow-path check is missing the extra checks that the gup-fast-path performs with pud_access_permitted. Later patches will align all checks to use the 'access_permitted' helper if the architecture provides it.
Note that the generic 'access_permitted' helper fallback is the simple _PAGE_RW check on architectures that do not define the 'access_permitted' helper(s).
--- arch/x86/include/asm/pgtable.h | 6 ++++++ include/asm-generic/pgtable.h | 8 ++++++++ include/linux/hugetlb.h | 8 -------- 3 files changed, 14 insertions(+), 8 deletions(-)
arch/x86/include/asm/pgtable.h +6 -0
@@ -1093,6 +1093,12 @@ static inline void pmdp_set_wrprotect(stclear_bit (_PAGE_BIT_RW, (unsigned long *)pmdp); } +#define pud_write pud_write +static inline int pud_write (pud_t pud) +{ +return pud_flags (pud) & _PAGE_RW; +} +/* * clone_pgd_range(pgd_t *dst, pgd_t *src, int count); *
include/asm-generic/pgtable.h +8 -0
@@ -814,6 +814,14 @@ static inline int pmd_write(pmd_t pmd)#endif /* __HAVE_ARCH_PMD_WRITE */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ +#ifndef pud_write +static inline int pud_write (pud_t pud) +{ +BUG (); +return 0 ; +} +#endif /* pud_write */ +#if !defined(CONFIG_TRANSPARENT_HUGEPAGE ) || \ (defined(CONFIG_TRANSPARENT_HUGEPAGE ) && \ !defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD ))
include/linux/hugetlb.h +0 -8
@@ -239,14 +239,6 @@ static inline int pgd_write(pgd_t pgd) }#endif -#ifndef pud_write -static inline int pud_write (pud_t pud) -{ -BUG (); -return 0 ; -} -#endif -#define HUGETLB_ANON_FILE "anon_hugepage"enum {
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/mm-hugetlbfs-introduce-split-to-vm_operations_struct.patch queue-4.14/ib-core-disable-memory-registration-of-filesystem-dax-vmas.patch queue-4.14/mm-introduce-get_user_pages_longterm.patch queue-4.14/mm-fail-get_vaddr_frames-for-filesystem-dax-mappings.patch queue-4.14/device-dax-implement-split-to-catch-invalid-munmap-attempts.patch queue-4.14/v4l2-disable-filesystem-dax-mapping-support.patch queue-4.14/mm-fix-device-dax-pud-write-faults-triggered-by-get_user_pages.patch queue-4.14/mm-madvise.c-fix-madvise-infinite-loop-under-special-circumstances.patch