Skip to content

fix(driver): reject truncated inference command buffers - #6

Draft
nihar5hah wants to merge 1 commit into
knewnothing-git:mainfrom
nihar5hah:fix/infer-command-size
Draft

fix(driver): reject truncated inference command buffers#6
nihar5hah wants to merge 1 commit into
knewnothing-git:mainfrom
nihar5hah:fix/infer-command-size

Conversation

@nihar5hah

Copy link
Copy Markdown

Reject truncated inference command buffers

Target: https://github.com/knewnothing-git/gpusion-driver

GpusionSubmitCommand checks the INFER payload length using
sizeof(GPUSION_CMD_INFER). That identifier is the enum constant for the
command type, so the check measures an integer rather than the payload.
The intended structure typedef is GPUSION_INFER_CMD.

On the macOS arm64 host with this repository's non-Windows stubs, these
sizes are 4 bytes and 48 bytes respectively. A 16-byte advertised buffer
passes the initial header check and is incorrectly dispatched as INFER.

The patch changes only the sizeof operand and adds one standalone regression
check. It checks every advertised size from 0 through 47, the complete
48-byte INFER command, a header-only NOP, and failure/completion accounting.
Backing storage remains valid so the test reproduces the incorrect acceptance
without deliberately reading outside allocated memory.

Validation:

cc -std=c99 -Wall -Wextra -Werror tests/submit-command.test.c -o /tmp/gpusion-submit-test
/tmp/gpusion-submit-test
git diff --check

The check fails on upstream commit ebdbd24 at the 16-byte case and passes
with the one-line correction. Windows/WDK compilation and hardware behavior
were not tested. The full-size INFER success assertion describes the existing
routing stub, not successful model inference. This patch does not address
physical-address mapping or implement the inference backend.

Prepared with AI assistance. CONTRIBUTING.md lists a ₹250 bounty for a bug
report confirmed reproducible by the maintainer and supports UPI payments.
Please confirm whether this report qualifies and whether the bounty remains
funded. Payment details can be supplied through a private channel.

Closes #5.

Draft because the contribution guide requires Intel laptop validation for kernel changes (and AMD if available). Neither hardware validation nor a Windows/WDK build is available on this macOS host. The documented scripts/test.ps1 is absent from this checkout; the standalone check above was run instead.

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.

INFER size check uses enum value instead of payload structure

1 participant