-
Notifications
You must be signed in to change notification settings - Fork 8k
Bluetooth: ISO: Fix issue with CIG being terminated #97285
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
base: main
Are you sure you want to change the base?
Bluetooth: ISO: Fix issue with CIG being terminated #97285
Conversation
In the case of a CIG having multiple CIS, and all CIS has been requested to being disconnected (i.e. they all enter the BT_ISO_STATE_DISCONNECTING state), then when the first disconnect complete is handled in bt_iso_chan_disconnected, then the cig->state was prematurely set to BT_ISO_CIG_STATE_INACTIVE. This meant that if the application called bt_iso_cig_terminate when the 2nd CIS entered bt_iso_chan_disconnected and called chan->ops->disconnected(chan, reason) then the CIG would be removed. When the CIS then entered bt_iso_cleanup_acl, it would access removed data from cleanup_cig. Change bt_iso_chan_disconnected to not allow the termination of the CIG until all CIS have entered the BT_ISO_STATE_DISCONNECTED state. Signed-off-by: Emil Gydesen <[email protected]>
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.
Pull Request Overview
This PR fixes a race condition in Bluetooth ISO CIG (Connected Isochronous Group) termination where a CIG could be prematurely terminated while CIS (Connected Isochronous Stream) channels were still disconnecting, leading to potential access of freed memory.
- Modified the CIG termination logic to wait for all CIS channels to reach
BT_ISO_STATE_DISCONNECTED
before allowing termination - Added test coverage to verify that
bt_iso_cig_terminate
correctly fails when CIS channels are still connected
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
subsys/bluetooth/host/iso.c | Fixed the state check to prevent premature CIG termination by waiting for all channels to be fully disconnected |
tests/bsim/bluetooth/host/iso/cis/src/cis_central.c | Added test logic to track connected channels and verify CIG termination behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
163a750
to
b75f069
Compare
|
Will follow up with a test that ensures this fix as well as enuring correct behavior in the future |
In the case of a CIG having multiple CIS, and all CIS has been requested to being disconnected (i.e. they all enter the BT_ISO_STATE_DISCONNECTING state), then when the first disconnect complete is handled in bt_iso_chan_disconnected, then the cig->state was prematurely set to BT_ISO_CIG_STATE_INACTIVE. This meant that if the application called bt_iso_cig_terminate when the 2nd CIS entered bt_iso_chan_disconnected and called chan->ops->disconnected(chan, reason) then the CIG would be removed. When the CIS then entered bt_iso_cleanup_acl, it would access removed data from cleanup_cig.
Change bt_iso_chan_disconnected to not allow the termination of the CIG until all CIS have entered the BT_ISO_STATE_DISCONNECTED state.
fixes #96155