diff options
| author | 2022-05-02 13:49:24 +0200 | |
|---|---|---|
| committer | 2022-05-02 13:49:24 +0200 | |
| commit | 35a7609639c49f76f13f206402cbf692c4ae3e4e (patch) | |
| tree | 55c8cf59f8bac0754eff06a3f102d2d819dc39ed /mm/userfaultfd.c | |
| parent | misc/pvpanic: Convert regular spinlock into trylock on panic path (diff) | |
| parent | Linux 5.18-rc5 (diff) | |
| download | linux-dev-35a7609639c49f76f13f206402cbf692c4ae3e4e.tar.xz linux-dev-35a7609639c49f76f13f206402cbf692c4ae3e4e.zip | |
Merge 5.18-rc5 into char-misc-next
We need the char-misc fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/userfaultfd.c')
| -rw-r--r-- | mm/userfaultfd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 0cb8e5ef1713..e9bb6db002aa 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -72,12 +72,15 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, _dst_pte = pte_mkdirty(_dst_pte); if (page_in_cache && !vm_shared) writable = false; - if (writable) { - if (wp_copy) - _dst_pte = pte_mkuffd_wp(_dst_pte); - else - _dst_pte = pte_mkwrite(_dst_pte); - } + + /* + * Always mark a PTE as write-protected when needed, regardless of + * VM_WRITE, which the user might change. + */ + if (wp_copy) + _dst_pte = pte_mkuffd_wp(_dst_pte); + else if (writable) + _dst_pte = pte_mkwrite(_dst_pte); dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl); |
