Commit 2c7ad9a
fs/proc/task_mmu: fix uffd-wp confusion in pagemap_scan_pmd_entry()
pagemap_scan_pmd_entry() checks if uffd-wp is set on each pte to avoid
unnecessary if set. However it was previously checking with
`pte_uffd_wp(ptep_get(pte))` without first confirming that the pte was
present. It is only valid to call pte_uffd_wp() for present ptes. For
swap ptes, pte_swp_uffd_wp() must be called because the uffd-wp bit may be
kept in a different position, depending on the arch.
This was leading to test failures in the pagemap_ioctl mm selftest, when
bringing up uffd-wp support on arm64 due to incorrectly interpretting the
uffd-wp status of migration entries.
Let's fix this by using the correct check based on pte_present(). While
we are at it, let's pass the pte to make_uffd_wp_pte() to avoid the
pointless extra ptep_get() which can't be optimized out due to READ_ONCE()
on many arches.
Link: https://lkml.kernel.org/r/20240429114104.182890-1-ryan.roberts@arm.com
Fixes: 12f6b01 ("fs/proc/task_mmu: add fast paths to get/clear PAGE_IS_WRITTEN flag")
Closes: https://lore.kernel.org/linux-arm-kernel/ZiuyGXt0XWwRgFh9@x1n/
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent c70dce4 commit 2c7ad9a
1 file changed
Lines changed: 13 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | | - | |
| 1820 | + | |
1821 | 1821 | | |
1822 | | - | |
1823 | | - | |
1824 | 1822 | | |
1825 | 1823 | | |
1826 | 1824 | | |
| |||
2175 | 2173 | | |
2176 | 2174 | | |
2177 | 2175 | | |
2178 | | - | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
2179 | 2180 | | |
2180 | | - | |
| 2181 | + | |
2181 | 2182 | | |
2182 | 2183 | | |
2183 | 2184 | | |
| |||
2190 | 2191 | | |
2191 | 2192 | | |
2192 | 2193 | | |
| 2194 | + | |
2193 | 2195 | | |
2194 | | - | |
| 2196 | + | |
| 2197 | + | |
2195 | 2198 | | |
2196 | 2199 | | |
2197 | 2200 | | |
2198 | 2201 | | |
2199 | 2202 | | |
2200 | 2203 | | |
2201 | 2204 | | |
2202 | | - | |
| 2205 | + | |
2203 | 2206 | | |
2204 | 2207 | | |
2205 | 2208 | | |
| |||
2208 | 2211 | | |
2209 | 2212 | | |
2210 | 2213 | | |
| 2214 | + | |
2211 | 2215 | | |
2212 | | - | |
| 2216 | + | |
2213 | 2217 | | |
2214 | 2218 | | |
2215 | 2219 | | |
| |||
2224 | 2228 | | |
2225 | 2229 | | |
2226 | 2230 | | |
2227 | | - | |
| 2231 | + | |
2228 | 2232 | | |
2229 | 2233 | | |
2230 | 2234 | | |
| |||
0 commit comments