summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/mprotect.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 763409e62ef6..cccad7974b3b 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -338,8 +338,15 @@ static inline unsigned long change_pmd_range(struct mmu_gather *tlb,
}
if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
- if (next - addr != HPAGE_PMD_SIZE) {
+ if ((next - addr != HPAGE_PMD_SIZE) ||
+ uffd_wp_protect_file(vma, cp_flags)) {
__split_huge_pmd(vma, pmd, addr, false, NULL);
+ /*
+ * For file-backed, the pmd could have been
+ * cleared; make sure pmd populated if
+ * necessary, then fall-through to pte level.
+ */
+ change_pmd_prepare(vma, pmd, cp_flags);
} else {
/*
* change_huge_pmd() does not defer TLB flushes,