Skip to content

t_hid: pass a three-axis rotation to dm_motion_set_switch (read past the array) - #443

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:t-hid-rot-array
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:t-hid-rot-array

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

A one-line test fix, found by the asan target of #412.

t_motion_hid's forced-phone case (from ceaf6d6, #296) calls dm_motion_set_switch(0, (float[]){0, -1, 0}, (float[]){0}). The rotation is one float, but motion_set reads three (motion_map_apply, motion_fusion.h:45), so the test reads two floats past the array on the stack. It passes by chance. AddressSanitizer stops on it:

ERROR: AddressSanitizer: stack-buffer-overflow … in motion_map_apply motion_fusion.h:45
    #1 motion_update motion_fusion.h:70
    #2 motion_set hle_hid.c:353
    #3 dm_motion_set_switch hle_hid.c:363
    #4 t_motion_hid t_hid.c:352

The rotation is now (float[]){0, 0, 0}, which is what the case means: no rotation. The host code is fine; only the test was wrong.

Checked: make -C dm/host/tests run passes (hid players: 119 checks, 0 failed), and #412's asan target no longer reports it. #412 is rebased on top of this.

The forced-phone case of t_motion_hid (ceaf6d6) passed (float[]){0} as the
rotation, one float, while motion_set reads three (motion_map_apply in
motion_fusion.h), so the test read two floats past the array on the stack.
It passed by chance; AddressSanitizer reports a stack-buffer-overflow at
motion_fusion.h:45 (found by the asan target of seedds#412). The rotation is now
(float[]){0, 0, 0}, which is what the case means: no rotation.

Checked: make -C dm/host/tests run passes (hid players: 119 checks), and
with seedds#412's asan target the report is gone.
seedds added a commit that referenced this pull request Oct 27, 2026
Integrate the sanitizer targets, HID fixture correction and pinned Xcode
27.1 CI toolchain from #412, #443 and #421. Select the matching runner for
the new sanitizer job as well as the four existing jobs.

Decode audio command headers without alignment assumptions and validate
their extents before consuming them. Finish AudioUnit construction before
publishing an output to lifecycle and watchdog readers. Publish pthread
handles under the scheduler lock and serialize startup, priority and QoS
fields with their readers. Remove all three real-bug suppressions.

Add unaligned/truncated header coverage, an output-publication assertion
and priority/QoS registration checks, including QoS-enabled TSan CI cases.
Document the mechanisms and retain only fixture/framework exceptions.

Plain host, ASan/UBSan, TSan, 40 QoS startup stress runs, the complete Metal
graphics suite, 525 Python tests (20 skipped), lint, all 178 iOS source
compiles and the unsigned synthetic iOS app build passed. Gameplay
regression results are reported with the PR follow-up.

Fixes #409
Fixes #410
Fixes #411

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Applied directly to main in ce99604, with v0lumehi credited as co-author.

I reproduced the original stack-buffer-overflow under ASan: the forced-phone case supplied one rotation float to a three-axis reader. The three-zero rotation fixes the test fixture at its cause; the host motion implementation is unchanged. All 119 HID checks pass, including the full host ASan/UBSan suite.

The sanitizer/toolchain integration and root fixes for #409–#411 are documented in the completed validation report. Closing because this fix is now on main.

@seedds seedds closed this Oct 27, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
Integrate the sanitizer targets, HID fixture correction and pinned Xcode
27.1 CI toolchain from seedds#412, seedds#443 and seedds#421. Select the matching runner for
the new sanitizer job as well as the four existing jobs.

Decode audio command headers without alignment assumptions and validate
their extents before consuming them. Finish AudioUnit construction before
publishing an output to lifecycle and watchdog readers. Publish pthread
handles under the scheduler lock and serialize startup, priority and QoS
fields with their readers. Remove all three real-bug suppressions.

Add unaligned/truncated header coverage, an output-publication assertion
and priority/QoS registration checks, including QoS-enabled TSan CI cases.
Document the mechanisms and retain only fixture/framework exceptions.

Plain host, ASan/UBSan, TSan, 40 QoS startup stress runs, the complete Metal
graphics suite, 525 Python tests (20 skipped), lint, all 178 iOS source
compiles and the unsigned synthetic iOS app build passed. Gameplay
regression results are reported with the PR follow-up.

Fixes seedds#409
Fixes seedds#410
Fixes seedds#411

Co-authored-by: v0lumehi <[email protected]>
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