-
Notifications
You must be signed in to change notification settings - Fork 39
fix(usb_host_hid): Harden hid_host_device_close() against concurrent access [WIP] (IEC-434) #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
roma-jam
wants to merge
3
commits into
master
Choose a base branch
from
fix/usb_host_hid_iface_teardown_race
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,48 @@ | ||
| ## 1.0.4 | ||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed a vulnerability with overwrite freed heap memory during `hid_host_get_report_descriptor()` | ||
| - Fixed race condition in hid_host_device_close() that could lead to double-free and list corruption under concurrent close/disconnect | ||
|
|
||
| ## [1.0.4] - 2025-09-24 | ||
|
|
||
| ### Added | ||
|
|
||
| - Added support for ESP32-H4 | ||
|
|
||
| ## 1.0.3 | ||
| ## [1.0.3] - 2024-08-20 | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed a bug with interface mismatch on EP IN transfer complete while several HID devices are present. | ||
| - Fixed a bug during device freeing, while detaching one of several attached HID devices. | ||
|
|
||
| ## 1.0.2 | ||
| ## [1.0.2] - 2024-01-25 | ||
|
|
||
| ### Added | ||
|
|
||
| - Added support for ESP32-P4 | ||
| - Fixed device open procedure for HID devices with multiple non-sequential interfaces. | ||
|
|
||
| ## 1.0.1 | ||
| ## [1.0.1] - 2023-10-04 | ||
|
|
||
| ### Added | ||
|
|
||
| - Added `hid_host_get_device_info()` to get the basic information of a connected USB HID device. | ||
|
|
||
| ### Fixed | ||
|
|
||
| - Fixed a bug where configuring the driver with `create_background_task = false` did not properly initialize the driver. This lead to `the hid_host_uninstall()` hang-up. | ||
| - Fixed a bug where `hid_host_uninstall()` would cause a crash during the call while USB device has not been removed. | ||
| - Added `hid_host_get_device_info()` to get the basic information of a connected USB HID device. | ||
|
|
||
| ## 1.0.0 | ||
| ## [1.0.0] - 2023-06-22 | ||
|
|
||
| ### Added | ||
|
|
||
| - Initial version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that the '2 calls to close' was present even before. Can you explain why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look! This is still Draft / [WIP]. I’m landing a minimal bug fix first and prepared a draft as we discussed yesterday; if needed, I’ll follow up with a separate refactor to simplify the close logic.
On the “two calls to close”: yes, that existed before. When the upper layer opens the interface, it owns a handle. The first call closes the interface; the second removes the interface from the list and invalidates the handle so the upper layer never holds a dangling reference.
I’m keeping that behavior unchanged here to keep the fix small and low-risk. If you see anything blocking for the bug-fix itself, please feel free to share; otherwise I’ll ping when it’s ready for full review.