Skip to content

eh: harden is_writable for PAGE_GUARD, multi-region spans, and lazy pages #626

Backlog

Description

@Grimkaaah

Problem

eh::is_writable (used by emulated CLZERO / ClzeroLoop) answers with a single VirtualQuery. That is wrong in four ways (originally listed as item 3 of #278; items 1–2 are on main, item 4 is #321):

  1. PAGE_GUARD. PAGE_READWRITE | PAGE_GUARD (0x104) passes & (PAGE_READWRITE | PAGE_EXECUTE_READWRITE) != 0, so the VEH can write through a guard page instead of letting the real fault happen.
  2. One region only. A ClzeroLoop can cover adjacent committed runs with different protect; one query only sees the first.
  3. Unchecked va + bytes. A wrapping end is undefined.
  4. Lazy physical pages. A page still in MEM_RESERVE (lazy map) makes is_writable false → 0xC000001D, instead of committing via lazy::ensure and zeroing.

Plan

Match the shape of dstorage::writable: checked_add → lazy::ensure → UMA coherent-window fast path → walk every VirtualQuery region covering [va, end), requiring a writable protect and no PAGE_GUARD. Unit tests with VirtualAlloc for guard, multi-region, hole, overflow, and a lazy page.

Complements #501 (sparse-window fast path); does not touch the CLWB race (#321).

Tracking

Split out of #278 item 3 so the fix can land as one small PR.

Activity

  1. Grimkaaah commented on Nov 24, 2026

    @Grimkaaah
    Author

    Complete PR: #523 (rebased, smoke on main + head, lib tests 648 passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions