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

Closed
opened 2026-11-24 00:49:23 +00:00 by Cattn · 4 comments
Cattn commented 2026-11-24 00:49:23 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by Cattn on 2026-11-24T00:49:23Z.


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.

github.com/ivall/xcl@2997c9aca6/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.

<!-- greyfinch-sync:ivall/xcl:issue:6572038207 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/476). Originally posted by [Cattn](https://github.com/Cattn) on 2026-11-24T00:49:23Z. --- 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.
requiemsnkrp commented 2026-11-24 07:05:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by requiemsnkrp on 2026-11-24T00:55:37Z.


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 #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).

<!-- greyfinch-sync:ivall/xcl:comment:7118577944 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/476#issuecomment-7118577944). Originally posted by [requiemsnkrp](https://github.com/requiemsnkrp) on 2026-11-24T00:55:37Z. --- 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 #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).
papasmurph0 commented 2026-11-24 07:05:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by papasmurph0 on 2026-11-24T01:37:52Z.


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:

  • A queue holding a request whose destination array had a 0 entry at enqueue doesn't submit by itself.
  • The title's Submit reads the missing entries again on the title's own thread, through ReadProcessMemory as at enqueue.
  • #289's reread stays only as a fallback.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7119292278 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/476#issuecomment-7119292278). Originally posted by [papasmurph0](https://github.com/papasmurph0) on 2026-11-24T01:37:52Z. --- **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: - A queue holding a request whose destination array had a `0` entry at enqueue doesn't submit by itself. - The title's `Submit` reads the missing entries again on the title's own thread, through `ReadProcessMemory` as at enqueue. - #289's reread stays only as a fallback. 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.*
requiemsnkrp commented 2026-11-24 07:05:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by requiemsnkrp on 2026-11-24T01:46:30Z.


@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).

<!-- greyfinch-sync:ivall/xcl:comment:7119434134 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/476#issuecomment-7119434134). Originally posted by [requiemsnkrp](https://github.com/requiemsnkrp) on 2026-11-24T01:46:30Z. --- @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)._
badoomtch commented 2026-11-24 09:07:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by badoomtch on 2026-11-24T08:05:03Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7125705448 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/476#issuecomment-7125705448). Originally posted by [badoomtch](https://github.com/badoomtch) on 2026-11-24T08:05:03Z. --- 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 in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#471
No description provided.