Bluetooth: protect le accept and resolv lists with hdev->lock
Subsystems (2)
PATCH 1/1 Bluetooth: protect le accept and resolv lists with hdev->lock
Concurrent operations from events on le_{accept,resolv}_list are currently unprotected by hdev->lock.
Most existing code do already protect the lists with that lock. This can be observed in hci_debugfs and hci_sync.
Add the protection for these events too.
---
Note:
I am currently working on a static analyser to detect missing locks using type-based static analysis as my master's thesis in order to obtain my master's degree.
If you would like to have more details, please let me know. This was a reported case. I manually verified the report by looking at the code, so that I do not send wrong information or patches. After concluding that this seems to be a true positive, I created this patch. This was compile-tested and runtime-tested on x86_64. This issue was found on Linux v5.17.4.
net/bluetooth/hci_event.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/bluetooth/hci_event.c +12 -0
@@ -1835,7 +1835,9 @@ static u8 hci_cc_le_clear_accept_list(struct hci_dev *hdev, void *data,if (rp->status)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_clear (&hdev->le_accept_list); +hci_dev_unlock (hdev);return rp->status; }
@@ -1855,8 +1857,10 @@ static u8 hci_cc_le_add_to_accept_list(struct hci_dev *hdev, void *data,if (!sent)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_add (&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); +hci_dev_unlock (hdev);return rp->status; }
@@ -1876,8 +1880,10 @@ static u8 hci_cc_le_del_from_accept_list(struct hci_dev *hdev, void *data,if (!sent)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_del (&hdev->le_accept_list, &sent->bdaddr, sent->bdaddr_type); +hci_dev_unlock (hdev);return rp->status; }
@@ -1949,9 +1955,11 @@ static u8 hci_cc_le_add_to_resolv_list(struct hci_dev *hdev, void *data,if (!sent)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_add_with_irk (&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type, sent->peer_irk, sent->local_irk); +hci_dev_unlock (hdev);return rp->status; }
@@ -1971,8 +1979,10 @@ static u8 hci_cc_le_del_from_resolv_list(struct hci_dev *hdev, void *data,if (!sent)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_del_with_irk (&hdev->le_resolv_list, &sent->bdaddr, sent->bdaddr_type); +hci_dev_unlock (hdev);return rp->status; }
@@ -1987,7 +1997,9 @@ static u8 hci_cc_le_clear_resolv_list(struct hci_dev *hdev, void *data,if (rp->status)return rp->status; +hci_dev_lock (hdev);hci_bdaddr_list_clear (&hdev->le_resolv_list); +hci_dev_unlock (hdev);return rp->status; }
Signature · 1 line
2.35.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=634829
---Test result---
Test Summary:
CheckPatch PASS 1.81 seconds GitLint PASS 1.06 seconds SubjectPrefix PASS 0.91 seconds BuildKernel PASS 39.15 seconds BuildKernel32 PASS 35.25 seconds Incremental Build with patchesPASS 47.65 seconds TestRunner: Setup PASS 588.43 seconds TestRunner: l2cap-tester PASS 21.02 seconds TestRunner: bnep-tester PASS 7.75 seconds TestRunner: mgmt-tester PASS 126.80 seconds TestRunner: rfcomm-tester PASS 11.60 seconds TestRunner: sco-tester PASS 11.37 seconds TestRunner: smp-tester PASS 11.30 seconds TestRunner: userchan-tester PASS 7.83 seconds
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:
Quoted 11 lines · On Sat, 23 Apr 2022 00:31:17 +0200 you wrote:
Concurrent operations from events on le_{accept,resolv}_list are currently unprotected by
hdev->lock.
Most existing code do already protect the lists with that lock. This can be observed inhci_debugfsandhci_sync.
Add the protection for these events too.Fixes b950aa88638c ("Bluetooth: Add definitions and track LE resolve list modification")Fixes 0f36b589e4ee ("Bluetooth: Track LE white list modification via HCI commands")Signed-off-by Niels Dossche <[email protected]>[...]
Here is the summary with links:
- Bluetooth: protect le accept and resolv lists with hdev->lock
https://git.kernel.org/bluetooth/bluetooth-next/c/df50527dbc32
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html