Repository navigation
selftests/arm64: check that a uffd-wp window's populated neighbours read zero - #2869
Conversation
…ead zero marker_window() checks that one write into a window write-protected before its first touch maps the whole native page at once, and that the neighbours keep their uffd-wp bit. It never read the neighbours, so a populate path that left stale data in their slots would pass. Check that pages 2 and 3 read zero after the first write. The loop after it still expects their WP bit, so it also shows that a read does not clear it. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
|
Review at a5343b2. Thanks, this closes the gap in One optional suggestion. Feel free to skip it.
Looks good to me otherwise. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at live head a5343b255ee7d0fc55359f666b986eb45855be0e (CI green: host-tests).
Test Validity & Checklist Summary
- Bounds & ordering:
worker()callsmarker_window(ps, native)only whenps < native(uffd-wp-init.c:825), so on arm64 (16K/4K,64K/4K,64K/16K)native >= 4 * psalways holds anda[2 * ps]/a[3 * ps]are strictly in-bounds. Becauseaescapes toioctl/physical/pagemapbefore and after line 470, the compiler cannot elide the loads. The subsequent loop at lines 473–476 re-checks((pagemap(a + i, ps) >> 57) & 1) == (i > ps), verifying both that the populated neighbours read zero and that reading them preserves their uffd-wp bits. - §1 No model gating: Pass (arch-generic arm64 selftest, no model/board gating).
- §2 Production-ready: Pass (selftest-only change, no hacks/delays/parameters).
- §3 Safety: Pass (userspace selftest only).
- §4 Clean-room & attribution: Pass. Single human commit (
Jonathan Goyvaerts), validSigned-off-by, zero AI trailers in commit. - §5 Evidence: Pass for a userspace selftest-only PR — executed on QEMU KVM arm64 16K (
user4k=on) at base110861f4333e(29/29UFFD CONTRACT PASS), plus negative-mutation proof (CHECK(a[2 * ps] || a[3 * ps])failing at line 470). - §6 Naming: Pass.
Optional non-blocking suggestion
- Line 470 checks only byte 0 of neighbour pages 2 and 3 (leaving page 0 before
a[0] = 0xa5, pages 4..15 on 64K native, and non-zero bytes at offset > 0 unchecked). Scanning all bytes of alli != psneighbour pages beforea[0] = 0xa5would make the check stricter, though this PR strictly improves coverage as-is.
Assisted-by: LLM (Gemini 4 Neon)
3883172
into
aurora-silicon:integration/aurora
|
Ran on hardware: J616s (M4 Pro, 16K kernel, Assisted-by: LLM (Claude:Opus 5.5) |
Follow-up to #2225, from RyanTheTide's merge-train review (nits 2 and 3).
Nit 3 (this commit).
marker_window()intools/testing/selftests/arm64/user4k/uffd-wp-init.cchecked that one write into a window write-protected before its first touch maps the whole native page in order, and that the neighbours keep their uffd-wp bit. It never read the neighbours, so a populate path that left stale data in their slots would still pass. It now checks!a[2 * ps] && !a[3 * ps]right after the first write. The loop after it still expects pages 2 and 3 to carry the uffd-wp bit, so it also shows that a read leaves the bit alone. Selftest only, no kernel change.Nit 2 (user-visible effects the #2225 commit message listed only in part). After one write into a WP-before-touch window, the populated neighbours are present pages. Besides RSS and
PAGE_IS_PRESENT, they also count inmincore()and in/proc/pid/smapsRss. CRIU-style dumpers that use PAGEMAP_SCAN dump them as present but unwritten zero pages.noneneighbours on this path already behave the same way, so nothing new for them. That commit is merged, so the note goes here instead of into its message.Tested (qemu, 16K kernel,
user4k=on)Kernel: integration/aurora
110861f4333e(this branch's base, which has #2225),arm64_user4k.config+USERFAULTFD,NET,UNIX,CGROUPS,MEMCG,FAULT_INJECTION,FAILSLAB,FAULT_INJECTION_DEBUG_FS. The staticuffd-wp-initbinary from this commit is/init; KVM,-cpu max -smp 4 -m 2048, a 512M swap disk.UFFD CONTRACT PASS, 29/29 (16K worker 13/13 + status, 4K worker 14/14 + status), includingok - uffd ABI 4K unpopulated WP first write: one native page, neighbours WP.CHECK(a[2 * ps] || a[3 * ps])) in a throwaway build. It fails at that line:not ok - uffd line=470,UFFD CONTRACT FAIL.checkpatch: 0 errors, 0 warnings. The binary builds with
-Wall -Wextraand no warnings.Assisted-by: LLM (Claude:Opus 5.5)