runtime: check the RFC 1950 codec's refusals #1726
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1733"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T17:56:38Z.
Refs #1149.
Change
src/dstorage_rfc1950.hdeclares the CPU side of the optional DirectStorage RFC 1950 fixture (src/dstorage_rfc1950.cpp):decodehandles oneDSTORAGE_CUSTOM_DECOMPRESSION_REQUESTwith zlib. Before zlib runs, it refuses any format other thanDSTORAGE_CUSTOM_COMPRESSION_0and any non-zero flag withE_NOTIMPL. It refuses a null or empty source or destination, or a size aboveULONG_MAX, withE_INVALIDARG.complete_onedequeues one job, decodes it and publishes the result under the request's ID. It returnsE_POINTERfor a null queue andS_FALSEfor an empty one. Until a job is dequeued,decodedreads{E_PENDING, 0, 0}.One test reaches it: the six
dstorage_rfc1950_*scenarios oftests/dstorage_rfc1950_check.cpp(success,truncated,checksum,trailing,oversize,undersize). They are registered only whenDSTORAGE_SDK_ROOTis set, so CI does not build them. Each scenario sends one well-formed custom-format-zero request through a real file queue, so no refusal path ran. 12 of 18 single-point mutants left all six passing (table below).New
refusalsscenario. It callsdecodedirectly with hand-built requests, each starting from a valid 116-byte stream and a 768-byte guarded destination:baselineS_OK, 116 consumed, 768 produced, bytes matchformat_custom_1:DSTORAGE_CUSTOM_COMPRESSION_0 + 1E_NOTIMPL< CUSTOM_0test would accept itformat_gdeflateE_NOTIMPLflag_dest_in_upload_heapE_NOTIMPLnull_src,null_dstE_INVALIDARGnull_dstwithout its check writes through a null pointer)zero_src,zero_dstE_INVALIDARG0x8007000dthat zlib's failure would givesrc_over_ulong_max,dst_over_ulong_max: size + 2^32E_INVALIDARGnull_queue:complete_one(nullptr, decoded)with a staledecodedE_POINTER,decoded=E_PENDING, zero countsEach refusal must also report zero bytes consumed and produced and leave the destination and its guards unchanged. The scenario prints one line per case and every failing case as
FAIL: refusals <case>: .... The six queue scenarios now also check that their final empty dequeue leavesdecodedatE_PENDINGwith zero counts. No existing check was changed.Negative control:
dstorage_rfc1950_refusals_truncation_controlbuilds the same check against a build-tree copy ofdstorage_rfc1950.cppwithoutrequest.SrcSize > ULONG_MAX ||. CMake stops withFATAL_ERRORif that text is gone and re-runs when the source file changes (CMAKE_CONFIGURE_DEPENDS). The test usesPASS_REGULAR_EXPRESSION "FAIL: refusals src_over_ulong_max: status 0x8007000d"instead ofWILL_FAIL, so it passes only when the check reports this specific defect. A crash does not pass it. When run directly, the control printsFAIL: refusals src_over_ulong_max: status 0x8007000d consumed=116 produced=768, expected 0x80070057, passes the other ten cases and exits 1.The change touches
tests/dstorage_rfc1950_check.cpp(one new function, amainbranch and one check after the last dequeue) and theDSTORAGE_SDK_ROOTblock ofCMakeLists.txt(refusalsadded to the scenario list, plus the control). It also adds a paragraph to "Windows file-to-memory RFC 1950 requests" indocs/experiments.md.src/dstorage_rfc1950.*is unchanged.Verification
Commit
eb913fc7oncb6f71d4(main),devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260. DirectStorage 1.3.0 NuGet package extracted underout/dstorage-sdk. zlib 1.3.1 (zlib-1.3.1.tar.gz, SHA-2569a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23) was built as a Releasezlibstaticwith/MD, and its library and headers were copied underout/zlib-install. No GPU is involved; the queue uses a memory destination.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to
src/dstorage_rfc1950.cppalone, rebuiltdstorage_rfc1950_checkand ran the scenarios, then reverted. "Existing" is the six queue scenarios on the unchanged test file andCMakeLists.txt. "With the new cases" addsrefusalsand the empty-dequeue check. For that run I took out theCMAKE_CONFIGURE_DEPENDSline, so the control's configure guard would not stop theSrcSizemutant. None of this is committed.format_custom_1,format_gdeflate)!=becomes<format_custom_1)Flagstest droppedflag_dest_in_upload_heap)E_NOTIMPLbecomesE_INVALIDARG!SrcBufferdroppednull_src:0x8007000d)!DstBufferdropped!SrcSizedroppedzero_src)!DstSizedroppedzero_dst)SrcSize > ULONG_MAXdropped (the control)src_over_ulong_max)E_NOTIMPL!queuedroppeddecodednot resetused != SrcSizedroppedtrailing)written != DstSizedroppedoversize)Id + 1S_OKS_OKpublished for every requestsuccess)Not pinned or not run
DstSize > ULONG_MAXmutant was not run. Without the bound,decodeallocatesDstSizebytes (4 GiB here) before zlib runs, and the Debug heap fills that block. By reading the code, it would returnE_OUTOFMEMORYor0x8007000dinstead ofE_INVALIDARG, sodst_over_ulong_maxwould kill it, but I did not measure that.Z_MEM_ERRORtoE_OUTOFMEMORYmapping and the failed allocation path. Neither is reachable without an allocation failure.complete_onepassing a failedGetRequeststhrough. The DirectStorage queue gives no way to make that call fail.flag_dest_in_upload_heappins the current refusal of upload-heap destinations. If the codec later accepts them, that case should change with it.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:04:28Z.
Review: COMMENTED
Peer review of PR #1733 at head
eb913fc72f8dcd25bba0e4dfeb49ae53f61d34b1.Summary
CMakeLists.txt(insideif(DSTORAGE_SDK_ROOT)),tests/dstorage_rfc1950_check.cpp, anddocs/experiments.md. Nosrc/files were modified. Title-neutral, MIT clean-room.refusals()exercisesdstorage_rfc1950::decode()anddstorage_rfc1950::complete_one()directly against real refusal paths (E_NOTIMPLfor non-zero custom format,GDEFLATE, andDSTORAGE_CUSTOM_DECOMPRESSION_FLAG_DEST_IN_UPLOAD_HEAP;E_INVALIDARGfor null/zero buffers and> ULONG_MAXsizes;E_POINTERand{E_PENDING, 0, 0}reset for a null queue), while also checking guard bytes and zero byte counts. Therun()scenarios also verify that the final empty-queuecomplete_one()resetsdecodedtoE_PENDINGwith zero counts.dstorage_rfc1950_refusals_truncation_controlinCMakeLists.txtstripsrequest.SrcSize > ULONG_MAX ||from a build-tree copy ofsrc/dstorage_rfc1950.cpp(guarded byCMAKE_CONFIGURE_DEPENDSandFATAL_ERRORif the anchor disappears) and requiresPASS_REGULAR_EXPRESSION "FAIL: refusals src_over_ulong_max: status 0x8007000d"so a crash cannot pass.Checks executed
prep-verify 1733):python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1733 --dir /tmp/rev-x2w-84/1733 --json->git_diff_check: PASS,docs_links_check: PASS,bidi_controls_check: PASS,py_compile: PASS.win2025 1733):python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 1733 --targets dstorage_rfc1950_check,dstorage_rfc1950_truncation_control --regex "dstorage_rfc1950_.*"-> failed at build (ninja: error: unknown target 'dstorage_rfc1950_check') becauseDSTORAGE_SDK_ROOTandZLIB_ROOTare not provisioned on the Win2025 verification node (C:\x2w\outcontains onlybuild,pe-env,tools). Consequently, Win2025 Debug, Release/O2, and thesrc/dstorage_rfc1950.cppmutation check could not be executed locally here.AI-assisted; commands listed were executed locally.
upstream-sync referenced this pull request2026-11-24 19:01:36 +00:00