HID: asus: fix Ally X input-report size validation (residual audit fixes after ally branch rewrite) - #6
HID: asus: fix Ally X input-report size validation (residual audit fixes after ally branch rewrite)#6jlobue10 wants to merge 14 commits into
Conversation
hid-asus.c audit — NeroReflex/linux
|
The ROG ally needs to have the EC string sent back after resuming from s2idle since the USB device can be turned completely off by the firmware when mcu_powersave firmware-attribute is set to 1. This may also be true for other laptops and certain features might stop working after the device exit from sleep. Signed-off-by: Denis Benato <denis.benato@linux.dev>
Implement the core functionality for ASUS handhelds: - extend functionality of hid-asus if driver is enabled - initialise the device to a "ready" state - implement Ally X input mapping - emit a single proper event for AC button long press Assisted-by: Claude:claude-fable-5 Signed-off-by: Khamunetri Clark <khamunetriclark@gmail.com> Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev> Signed-off-by: Jonathan LoBue <jlobue10@gmail.com>
Add the base configuration structures for the gamepad configuration, detect capabilities and initialize the device in a known state. Assisted-by: Claude:claude-fable-5 Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev> Signed-off-by: Jonathan LoBue <jlobue10@gmail.com>
ASUS ROG Ally handhelds support the vibration strength to be configured: add sysfs attributes to allow userspace configure motors vibration intensity. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev>
ROG Ally devices supports configuring joysticks inner and outer range: add sysfs attributes to allow userspace modifying the sensitivity of those controllers. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev>
ROG Ally devices allows configuring inner and outer ranges for triggers buttons on the back: allow userspace to configure the sesitivity by exposing sysfs attributes. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev>
ROG Ally devices allow configuring the anti-deadzone parameter for the resistive joysticks devices as over time those develops drift, therefore allow userspace to configure the anti-deadzone by exposing relevant sysfs attributes. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev>
ROG ally devices allows configuring the response curve of both joysticks, therefore add the ability of userspace to modify the response curve by exposing relevant sysfs attributes. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke Jones <luke@ljones.dev>
ROG ally devices supports a feature called turbo buttons that allows the user to quickly toggle button state by keeping a button pressed, therefore allow userspace to configure the feature by exposing relevant sysfs attributes. Assisted-by: claude-fable-5 Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Khamunetri Clark <khamunetriclark@gmail.com> Signed-off-by: Luke Jones <luke@ljones.dev> Signed-off-by: Jonathan LoBue <jlobue10@gmail.com>
Add support for buttons remapping: the ability to assign different button events to each one of the physical button on the device. Assisted-by: Claude:claude-fable-5 Signed-off-by: Luke Jones <luke@ljones.dev> Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: John LoBue Jonathan LoBue <jlobue10@gmail.com>
ROG Ally devices can emulate either a mouse+keyboard (desktop mode) or an gamepad device (xbox360 controller in ROG ally and a custom DInput device on newer models): add support for switching the current controller mode. Signed-off-by: Luke Jones <luke@ljones.dev> Signed-off-by: Denis Benato <denis.benato@linux.dev>
Unlike ROG ally the X version and following ones uses DInput protocol and the force feedback needs to be implemented as its protocol is vendor-specific, therefore add support for FF_RUMBLE with magnitude scaling on a work-queue based approach to avoid using possibly sleeping calls in atomic context. Assisted-by: gpt-5.3-codex Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Khamunetri Clark <khamunetriclark@gmail.com> Signed-off-by: Luke Jones <luke@ljones.dev>
ASUS ROG laptops supports a protocol called Aura to control LEDs over multiple zones: this protocol allows changing effects, colors, brightness and transitioning speed across different colors on certain effects. Add support for said protocol to allow complete customization of LEDs mounted on the ROG ally and laid out the foundation for all other laptops. Assisted-by: glm-5.2 Assisted-by: claude-fable-5 Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: ALTRI
…xes) Rebase onto the rewritten ally branch, which already incorporates most of the original 9-fix audit series. Remaining changes: - ally_x_input_report: shrink buttons[4] to buttons[3] so sizeof matches the real 16-byte 0x0B wire report (report ID + 12 axis bytes + 2 button bitmaps + 1 hat byte). The absorbed audit fix kept the over-declared struct, so the guard `size < 1 + sizeof(*in_report)` demands 17 bytes and rejects every gamepad report on Ally X hardware; input then falls through to generic HID handling on the N-KEY node. Field-verified on ROG Xbox Ally X (RC73XA): usbmon shows the interrupt-IN report is exactly 16 bytes. - response_curve_pct_store/response_curve_move_store: assign through a single pointer selected in the switch so the store happens in one place under the config mutex. - hid_asus_ally_probe error path: comment documenting why the cfg globals must be cleared on hid_asus_ally_init failure. - Normalize indentation of the ally_drvdata block (stray leading spaces introduced when the resume_work initializer was applied to the branch). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M3pWeekLNWsrqafc9erby3
36d1d0e to
43dec20
Compare
|
Rebased onto the rewritten First: thanks for folding the audit fixes (and the PR #2 mapping/long-press fixes) into the new series — most of this PR became redundant overnight, which is the good outcome. I've rebased it down to the residual delta (+40/−32). The critical bit that got missed: the
What's left in this PR after the rebase:
Cross-model note: we scrubbed this against the other models before rebasing. Also: your |
|
Hardware validation of the current The rewritten head incorporates this PR's critical fix ( Test setup: kernel 7.2.0-rc4 with the head's
Front-button semantics on this head, stable across every suspend cycle: front1 = F16 short / F17 long, front2 = PROG1 short and long (the merged convention — fine by us, see #2). Two minor notes, not worth PRs:
Thanks for absorbing the fixes — happy to re-test future heads on this hardware. |
Important
Rebased 2026-07-26 onto the rewritten
allybranch (9bc9553). The branch rewrite absorbed most of the original 9-fix series, so this PR is now just the residual delta (+40/−32). The one functional change remaining is critical: the rewrite kept the audit's report-size guard but not its field-testedbuttons[4]→buttons[3]correction, so the current branch tip rejects every 16-byte0x0Bgamepad report on Ally X hardware. Details in this comment. Remaining scope: (1)buttons[3]wire-size fix, (2) response-curve store style cleanup, (3) probe-error-path comment, (4) indentation normalization. The original pre-rebase description follows for reference.Security/lifecycle audit of hid-asus.c: 9 fixes, field-validated on Xbox Ally X
This PR carries the fixes from a source audit of
drivers/hid/hid-asus.conbranch
ally@bbd3c71a752f("HID: asus: tmp leds"), followed by a runtimevalidation pass on real hardware. Full audit write-up (analysis, failure
scenarios, and 4 investigated-and-rejected false positives) is posted as the first comment below.
The 9 findings
hat_values[]indexed by a raw wire byte — OOB read of kernel.rodataleaked to userspace viaABS_HAT0X/Y. Also present onmaster.ally_create_button_attributes(): inner loop clobbers the outer index — infinite loop, repeated double-kfreeof 48 objects, UAF insidesysfs_remove_group()hid_asus_ally_remove()never clearskeyboard_hdev/keyboard_input— UAF write fromhandle_ally_event()/ally_resume_work_fn()when the kbd interface tears down firstally_x_raw_event()casts a 15-byte payload onto&data[1]without checkingsize— a short transfer reads stale DMA buffer bytes (and feeds #1). Also present onmaster.ally_x_play_effect()can queueff_workaftercancel_work_sync()— flag test and queueing now both underff_lockINIT_DELAYED_WORKon a possibly-queuedresume_work+ unbalanced cancel — statically initialized, cancelled on every interface teardownRuntime validation (Xbox Ally X, 2026-07-25)
Test vehicle:
7.2.0-rc4CachyOS-deckify kernel + this branch's hid-asus,audited module built out-of-tree and exercised with
slub_debug=FZPon thekernel command line (freed-memory poisoning + redzones; neither installed
kernel has KASAN). Every phase below was followed by a kmsg scan for
BUG/oops/poison/redzone/WARN — all scans clean.
rtcwakecycles: rebind set, input nodes, config-marker survival, post-resume rumbleNot runtime-covered, for honesty's sake:
FAILSLABtoreach on real hardware. The fix strictly replaces an infinite loop, so the
risk of the fix being worse than the bug is nil.
reports on demand, and a uhid impostor doesn't survive this driver's
USB-interface probe requirements.
The validation loop caught a bug in the audit's own #4 fix
Worth calling out because it's also new information about the hardware: the
first version of the #4 fix required
size >= 1 + sizeof(struct ally_x_input_report)= 17 with the struct's existingbuttons[4]. On thewire, the Ally X's
0x0Binterrupt-IN report is exactly 16 bytes (usbmon:0b+ 12 axis bytes + 2 button bitmaps + 1 hat byte) —buttons[3]does notexist on the wire. That version rejected every real report; the custom gamepad
node went silent and input fell through to generic HID decode on the N-KEY
node, which kept a coincidental subset of buttons working (A/B/X, dpad,
triggers) while Y, bumpers, stick clicks, View/Menu/Xbox and both stick axes
died. The button matrix caught it immediately.
The shipped fix shrinks the struct to
buttons[3]sosizeofmatches thewire payload, and the full matrix passes 25/25. Two takeaways for the tree:
the trailing
buttons[4]byte inally_x_input_reportover-declares thereport, and any future size-validation there must use 16, not 17.
Notes
(
ally_detect_capabilitiesruns beforeally_gamepad_check_ready, so acold boot can race to all-support-flags-false) is still present on this
head and is not addressed by this series — it's a separate fix.
short / F17 long, right = PROG1 short and long (the adapted merge of the
PR HID: asus: fix CMD_SET_MAPPING packet layout + Xbox Ally X long-press codes (full test report inside) #2 long-press remap). Stable across all suspend cycles.
Test hardware: ASUS Xbox Ally X (0b05:1b4c). Happy to re-run any of this or
share raw logs/kmsg captures.
🤖 Generated with Claude Code