Skip to content

Commit 4980e83

Browse files
xzpeterakpm00
authored andcommitted
mm/pagemap: fix wr-protect even if PM_SCAN_WP_MATCHING not set
The new pagemap ioctl contains a fast path for wr-protections without looking into category masks. It forgets to check PM_SCAN_WP_MATCHING before applying the wr-protections. It can cause, e.g., pte markers installed on archs that do not even support uffd wr-protect. WARNING: CPU: 0 PID: 5059 at mm/memory.c:1520 zap_pte_range mm/memory.c:1520 [inline] Link: https://lkml.kernel.org/r/20231116201547.536857-3-peterx@redhat.com Fixes: 12f6b01 ("fs/proc/task_mmu: add fast paths to get/clear PAGE_IS_WRITTEN flag") Signed-off-by: Peter Xu <peterx@redhat.com> Reported-by: syzbot+7ca4b2719dc742b8d0a4@syzkaller.appspotmail.com Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Andrei Vagin <avagin@gmail.com> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 0dff1b4 commit 4980e83

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/proc/task_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ static int pagemap_scan_pmd_entry(pmd_t *pmd, unsigned long start,
21562156
return 0;
21572157
}
21582158

2159-
if (!p->vec_out) {
2159+
if ((p->arg.flags & PM_SCAN_WP_MATCHING) && !p->vec_out) {
21602160
/* Fast path for performing exclusive WP */
21612161
for (addr = start; addr != end; pte++, addr += PAGE_SIZE) {
21622162
if (pte_uffd_wp(ptep_get(pte)))

0 commit comments

Comments
 (0)