Skip to content

fix(wddm): reject undersized QueryAdapterInfo buffers - #18

Open
Neonstudio28 wants to merge 2 commits into
knewnothing-git:mainfrom
Neonstudio28:fix/query-adapter-output-size
Open

fix(wddm): reject undersized QueryAdapterInfo buffers#18
Neonstudio28 wants to merge 2 commits into
knewnothing-git:mainfrom
Neonstudio28:fix/query-adapter-output-size

Conversation

@Neonstudio28

Copy link
Copy Markdown

Summary

Fixes the output-buffer validation gap described in #15.

GpusionQueryAdapterInfo previously passed caller-controlled buffers directly to the DRIVERCAPS and QUERYSEGMENT helpers. Those helpers write complete WDDM structures, so truncated buffers could be overwritten. This change returns STATUS_BUFFER_TOO_SMALL before dispatching when OutputDataSize is smaller than the structure being written. The check covers QUERYSEGMENT, QUERYSEGMENT3, and QUERYSEGMENT4.

Validation

Added tests/query-adapter-output-size.test.c, a portable regression harness. Under AddressSanitizer and UndefinedBehaviorSanitizer it checks sizes 0, 1, size-1, exact size, and size+8 for all four affected query types. The harness passed and verified that undersized buffers remain unchanged and canaries remain intact.

Command:

cc -std=c99 -Wall -Wextra -Werror -fsanitize=address,undefined tests/query-adapter-output-size.test.c -o /tmp/query-adapter-output-size.test && /tmp/query-adapter-output-size.test

Terms and attribution

This PR is submitted against the report in #15, with the reporter credited for the finding. I noticed the current CONTRIBUTING.md says the project no longer runs a paid bounty program and only honours reports submitted while the earlier cash terms were listed. Please confirm whether this post-terms fix can receive any funded sponsorship or other payable award. If so, I can provide UPI or bank-transfer details privately; no payment information is included here.

AI assistance was used for the implementation and test drafting; the reproduction and test were run locally as described above.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The critical versioned-structure validation gap and moderate test-buffer coverage issue remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This pull request adds WDDM QueryAdapterInfo output-buffer validation and portable sanitizer regression tests.

Changes:

  • Adds size checks for DRIVERCAPS and segment-query outputs.
  • Tests boundary sizes and canary preservation.
File summaries
File Summary
tests/query-adapter-output-size.test.c Adds regression coverage; the test allocation does not fully cover DXGK_DRIVERCAPS.
driver/wddm/query_adapter_info.c Adds buffer checks, but v3/v4 queries use larger versioned structures than the legacy size checked.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

case DXGKQAITYPE_QUERYSEGMENT:
case DXGKQAITYPE_QUERYSEGMENT3:
case DXGKQAITYPE_QUERYSEGMENT4:
if (pQueryAdapterInfo->OutputDataSize < sizeof(DXGK_QUERYSEGMENTOUT)) {
Comment thread tests/query-adapter-output-size.test.c Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants