* [PATCH] Bluetooth: protect le accept and resolv lists with hdev->lock
@ 2022-04-22 22:31 Niels Dossche
2022-04-23 0:04 ` bluez.test.bot
2022-04-25 14:30 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Niels Dossche @ 2022-04-22 22:31 UTC (permalink / raw)
To: linux-bluetooth
Cc: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
Ankit Navik, Niels Dossche
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.
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 <dossche.niels@gmail.com>
---
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(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index abaabfae19cc..f314eb0bf284 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -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;
}
--
2.35.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: Bluetooth: protect le accept and resolv lists with hdev->lock
2022-04-22 22:31 [PATCH] Bluetooth: protect le accept and resolv lists with hdev->lock Niels Dossche
@ 2022-04-23 0:04 ` bluez.test.bot
2022-04-25 14:30 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2022-04-23 0:04 UTC (permalink / raw)
To: linux-bluetooth, dossche.niels
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bluetooth: protect le accept and resolv lists with hdev->lock
2022-04-22 22:31 [PATCH] Bluetooth: protect le accept and resolv lists with hdev->lock Niels Dossche
2022-04-23 0:04 ` bluez.test.bot
@ 2022-04-25 14:30 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2022-04-25 14:30 UTC (permalink / raw)
To: Niels Dossche
Cc: linux-bluetooth, marcel, johan.hedberg, luiz.dentz, ankit.p.navik
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Marcel Holtmann <marcel@holtmann.org>:
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 in hci_debugfs and hci_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 <dossche.niels@gmail.com>
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-25 14:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 22:31 [PATCH] Bluetooth: protect le accept and resolv lists with hdev->lock Niels Dossche
2022-04-23 0:04 ` bluez.test.bot
2022-04-25 14:30 ` [PATCH] " patchwork-bot+bluetooth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.