diff options
| author | Donggeun Yoo <donggeunyoo.kernel@gmail.com> | 2026-10-03 19:30:29 +0900 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-08 23:04:45 -0700 |
| commit | 5c116a8d8efabef535caa210140a83182f5fe451 (patch) | |
| tree | f7a13a7b808ede58c9e2c06dd49f69f8656fed61 /tools/lib/python/kdoc/python_version.py | |
| parent | 61192bf3db8a58ba9af50589be61304835e10380 (diff) | |
| download | linux-next-5c116a8d8efabef535caa210140a83182f5fe451.tar.gz linux-next-5c116a8d8efabef535caa210140a83182f5fe451.zip | |
userfaultfd: clear the inherited uffd bit in move_swap_pte()
Patch series "userfaultfd: clear the inherited uffd bit in
move_swap_pte()", v4.
UFFDIO_MOVE on a swapped-out page installs the source PTE at the
destination unchanged, so a uffd bit set on a write-protected or
RWP-protected source lands in a destination VMA that was never registered
for either, and nothing clears it afterwards. Patch 1 clears the bit,
then re-arms it if the destination is RWP-registered, which is what the
present-page and zeropage move paths already do. Patch 2 adds the tests
that catch it.
This patch (of 2):
UFFDIO_MOVE on a swapped-out page installs the source PTE at the
destination unchanged, so a uffd bit set on a write-protected or
RWP-protected source lands in a destination VMA that was never
registered for either. Nothing clears it there, and userspace sees:
- /proc/<pid>/pagemap reports the page as uffd-tracked (bit 57), both
while it is swapped out and after it is faulted back in.
- MADV_COLLAPSE fails with EINVAL on a range containing it, because the
collapse scan bails on a swap entry with the uffd bit set.
- With CONFIG_PAGE_TABLE_CHECK, faulting the page in warns.
do_swap_page() carries the bit into the present PTE and, since the
destination isn't WP-registered, also makes it writable:
WARNING: mm/page_table_check.c:202 at __page_table_check_ptes_set+0x185/0x1e0
Call Trace:
set_ptes+0x67/0xc0
do_swap_page+0x990/0xfe0
__handle_mm_fault+0x7d0/0xeb0
handle_mm_fault+0x9c/0x250
do_user_addr_fault+0x207/0x650
exc_page_fault+0x65/0x150
asm_exc_page_fault+0x26/0x30
Reaching it takes UFFDIO_MOVE out of a WP- or RWP-protected area into
one that isn't, on a page that is swapped out at the time. It hasn't
been seen in practice.
A resident page doesn't carry the bit, because move_present_ptes() builds
the destination PTE from dst_vma->vm_page_prot. Clear it on the moved
swap entry as well, then re-arm it if the destination is RWP-registered.
The WP case has been there since v6.8, where UFFDIO_MOVE was added.
Link: https://lore.kernel.org/20261003103030.63380-1-donggeunyoo.kernel@gmail.com
Link: https://lore.kernel.org/20261003103030.63380-2-donggeunyoo.kernel@gmail.com
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Assisted-by: LLM
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: <stable@vger.kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions
