Skip to content

DirectStorage: a deferred page-array entry is reread from title memory the title may have freed (#289) #476

Done

Description

@Cattn

From a static review (no builds or runs) of 2997c9a:

This follows up on #289. For destination entries that were zero at enqueue, the worker rereads the title's page array after checking readable(), which only checks memory accessibility at that point. If the array has been reused, the worker can pick up a different valid page number and copy to the wrong title page, or the read can fault if the memory is unmapped between the check and dereference. This is a memory-lifetime bug, and I found no indication of malicious code.

Require the title to keep any array with deferred entries valid until the request completes.

https://github.com/ivall/xcl/blob/2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21/crates/xcl/src/hle/dstorage.rs#L834-L849

Review by Claude Code (Claude Opus 5.5) with a gpt-6.2-sol audit subagent; I checked each point against the code.

Activity

  1. requiemsnkrp commented on Nov 24, 2026

    @requiemsnkrp
    Contributor

    I'll take this one, unless someone already has it in progress.

    Plan (small, one PR):

    • In execute, read the deferred entries with read_own (ReadProcessMemory on the process itself, which fails instead of faulting) rather than readable() + read_unaligned. If the array is unmapped between the check and the read, the request then fails with E_ACCESS_VIOLATION and the xcl-dstorage worker no longer takes the process down.
    • The wrong-page case cannot be told apart from a legitimate late fill: if the array is reused before the request's turn, the reread may still find a valid page number. The title has to keep an array with deferred entries valid until the request completes, which DirectStorage: a destination page array entry that is 0 at enqueue is read at the request's turn #289 already assumes. I will say so in the comment there; there is no code fix for it.
    • Test: requests with a deferred entry run while another thread decommits and recommits the array's page. Before the change the test process ends with 0xc0000005; after it, every request either completes or fails with E_ACCESS_VIOLATION.

    AI use: Claude Code (Claude Opus 5.5).

  2. papasmurph0 commented on Nov 24, 2026

    @papasmurph0

    Measured on a retail title; a change that narrows this window instead of widening it

    NVIDIA GeForce RTX 4080 SUPER (driver 610.88), Windows 11 26200. With a local counter by HRESULT, a run of main (2997c9a) past the title's account prompt had about 2,850 requests fail with E_ACCESS_VIOLATION (0x89240009) in 230 s. With extra logging on the refusal path, each one had a one-entry destination page array that was still 0 at the request's turn, after #289's reread.

    The half-full auto-submit runs these requests before the title fills the entry. The title fills it after EnqueueRequest and before its own Submit. Polling the array from the worker would fix the failures but lengthen the window this issue describes, so I'm proposing this instead:

    With that change the same run had no 0x89240009 failures. It narrows the window but doesn't close it, because the fallback still reads late. PR to follow.

    Measured and written with Claude Code (Claude Opus 5.5); I checked it before posting.

  3. requiemsnkrp commented on Nov 24, 2026

    @requiemsnkrp
    Contributor

    @papasmurph0 thanks for measuring it. Your ~2,850 0x89240009 in 230 s are streaming requests whose data never arrives, which is the bigger problem here. Rereading at the title's Submit addresses it, and #509 does not.

    #509 changes only how the worker's reread reads: read_own instead of readable() followed by a dereference, so an array unmapped in between fails the request instead of ending the process. That still matters for the fallback you keep. Both changes touch the same block of execute, so whichever lands second needs a small rebase. I'm happy to rebase #509 onto your PR, or you can build on #509, whichever you prefer.

    Written with Claude Code (Claude Opus 5.5).

  4. badoomtch commented on Nov 24, 2026

    @badoomtch

    I measured destination page arrays in three retail runs on an RTX 5080 using local instrumentation on af20b4b, before #289. The samples below are from explicit Submit on manual queues. They are separate runs.

    • Of 24,315 file requests that failed with 0x89240009 and had an incomplete destination list at Enqueue, 24,236 had every entry filled at Submit and no earlier non-zero ID to compare. In the other 79 requests at least one previously non-zero entry had changed. Those 79 lists also started incomplete.
    • In another run, 4,080 lists that were complete at Enqueue changed before Submit. All 5,712 replaced slots still referred to allocated old page IDs at Submit. Zero old IDs were unallocated. This measures the old pages’ allocation state. It leaves the title’s intended destination unknown.
    • In a third run, 17,639 requests shared the same table start with another pending request and had disjoint destination byte ranges in the Submit snapshot. None had an independently corroborated ID for a slot that was blank at Enqueue. The count is per request.

    This puts numbers on the ambiguity described in #509. A populated table and live page IDs at Submit alone cannot distinguish late publication from table reuse. These figures predate #289.

    AI use: OpenAI Codex checked the saved counters and the classification code and wrote this comment.

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