summaryrefslogtreecommitdiff
path: root/core/usbh_core.c
AgeCommit message (Collapse)Author
2026-07-17fix(usbh): bounds-check cur_ep before writing ep[] in ↵HEADmasteryi chen
parse_config_descriptor (#426) * fix(usbh): check cur_ep against CONFIG_USBHOST_MAX_ENDPOINTS before writing ep[] parse_config_descriptor() checks cur_ep_num (the interface descriptor's self-declared bNumEndpoints) against CONFIG_USBHOST_MAX_ENDPOINTS when the INTERFACE descriptor is parsed, but cur_ep (the actual write index, incremented once per ENDPOINT sub-descriptor encountered in the byte stream) is never bounds-checked in the USB_DESCRIPTOR_TYPE_ENDPOINT case before the memcpy. A non-conformant or malicious device can declare a small bNumEndpoints while still emitting more ENDPOINT descriptors than declared in the raw config descriptor byte stream, causing cur_ep to exceed CONFIG_USBHOST_MAX_ENDPOINTS and the memcpy to write past the ep[] array, past altsetting[], and potentially past the whole usbh_configuration struct. Add the same bounds check pattern already used for cur_iface and cur_alt_setting two cases above, applied to cur_ep before the memcpy. * Allow interfaces to use configured capacity Endpoint counts are quantities, so a declaration equal to the endpoint array capacity is valid. The per-index guard still rejects descriptors that contain more endpoint records than the storage can hold. Constraint: Preserve the new cur_ep index guard Confidence: high Scope-risk: narrow Tested: Real parser matrix for declared/actual 3/3, 4/4, 5/5, and 3/5; MinGW and WSL GCC13 ASan+UBSan Not-tested: Physical USB device enumeration
2026-07-14fix(security): check desc len overflowsakumisu
Signed-off-by: sakumisu <[email protected]>
2026-07-12update(security): check null pointer and overflowsakumisu
Signed-off-by: sakumisu <[email protected]>
2026-04-21fix(security): remove hport mutex safelysakumisu
Signed-off-by: sakumisu <[email protected]>
2026-04-17fix(class/hub): remove bus mutex, replace with mq to exit threadsakumisu
Signed-off-by: sakumisu <[email protected]>
2026-04-03fix(core): adjust init&deinit event callback positionsakumisu
Signed-off-by: sakumisu <[email protected]>
2026-03-30fix(core/usbh_core): fix desc length parsesakumisu
2025-12-17style: change \t to spacesakumisu
Signed-off-by: sakumisu <[email protected]>
2025-12-03fix(core): fix warningssakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-27feat(core/usbh_core): support custom config indexsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-24update(core): change assert with USB_ASSERT_MSGsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-20feat(core/usbh_core): support interfacenum match flagsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-13update(core/usbh_core): print interface num when load driversakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-11refactor(core/usbh_core): refactor lsusbsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-11-03update(core/usbh_core): add retry for control transfer, some devices are flakeysakumisu
Signed-off-by: sakumisu <[email protected]>
2025-08-30feat: host add event callback mechanism similar to deviceEgahp
* fix: fix warning for speed_table * fix(port/dwc2/usb_hc_dwc2): add roothub.speed init * feat(usbh_core): add event_callback * fix(usbh_hub): fix event device reset port * fix(usbh_hub): remove event init when init failed * feat(usbh_core): add default dummy_event_callback * fix(usbh_hub): emit reset event only on successful reset * fix(usbh_core): emit interface start only on successful connect class driver * feat(usbh_core): change event_callback to typedef * feat(port): update port usbh init params * doc: update usbh_initialize desc * fix(usbh_core): check result from ret == 0 change to ret >= 0 --------- Signed-off-by: egahp <[email protected]>
2025-08-27refactor(core/usbh_core): refactor devaddr allocation, use auto incrementsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-08-01update(core/usbh_core): check string support and then get string descsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-07-27update(core/usbh_core): do not assert when parse desc fail, just return errorsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-07-25update: add output_len param for usbh_get_string_descsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-07-20fix(core/usbh_core): change 2ms to 10ms because some platform's tick is ↵sakumisu
100hz then 2ms = 0ms, refs: #342 Signed-off-by: sakumisu <[email protected]>
2025-05-06update: add USB_ASSERT_MSG for common casesakumisu
Signed-off-by: sakumisu <[email protected]>
2025-04-30fix unused warningssakumisu
Signed-off-by: sakumisu <[email protected]>
2025-03-28fix: fix wformat warningssakumisu
Signed-off-by: sakumisu <[email protected]>
2025-03-28update: add usb align up for every buffer when use dcache clean&invalid apisakumisu
Signed-off-by: sakumisu <[email protected]>
2025-02-09fix(core/usbh_core): check hport is valid in usbh_control_transfersakumisu
Signed-off-by: sakumisu <[email protected]>
2025-02-07fix(core/usbh_core): return valid hport which is connectedsakumisu
Signed-off-by: sakumisu <[email protected]>
2025-01-25feat(core/usbh_core): add usbh_printf_setup api for debugsakumisu
Signed-off-by: sakumisu <[email protected]>
2024-12-20修复VID/PID匹配逻辑yangpeng
2024-12-09fix warningsakumisu
2024-10-31feat(core/usbh_core): add usbh_find_hubport apisakumisu
2024-10-30fix: rename class to class_code, for c++ compatibility (#269)electretmike
Co-authored-by: Michiel van Leeuwen <[email protected]>
2024-09-19chore: static code analysissakumisu
2024-09-16fix(core/usbh_core): Fix raw_config_desc heap out of boundsCCHhui
2024-09-07update(usbh_core): add terminate char for raw_config_descsakumisu
2024-08-24fix(core/usbh_core.c): fix error namesakumisu
2024-08-09Add PUSB2 and XHCI driver and RTOS glue (#236)zhugengyu
2024-07-23refactor(osal): use osal malloc and free, remove usb_malloc & usb_free macrosakumisu
2024-07-07update(hub): update hub macros and hub params for usb3.0sakumisu
2024-06-22update(core/usbh_core): do not use slist, we use recursionsakumisu
2024-06-17fix(core/usbh_core): fix missing free devaddr caused by 935325sakumisu
2024-06-07remove old xhci patchsakumisu
2024-05-15update(core/usbh_core): remove ununsed urb memsetsakumisu
2024-05-03adjust code ordersakumisu
2024-05-03support id table for multi vid pidsakumisu
2024-05-03move usbh_hubport_release api to coresakumisu
2024-04-25check class_driver is nullsakumisu
2024-04-25change INFO to DBGsakumisu
2024-04-07add config index to select multi configssakumisu
2024-04-03add check for wTotalLengthsakumisu