Bluetooth: mgmt: Fix heap overflow and race condition
Subsystems (3)
v5 cover Bluetooth: mgmt: Fix heap overflow and race condition
This patch resolves two vulnerabilities in mgmt_util.c:
1. A heap buffer overflow due to missing length validation.
2. Race conditions in list handling, fixed using the existing mutex.
Changes in v5:
- Combined both fixes into a single patch for atomic application.
- Switched to using 'mgmt_pending_lock' (mutex) instead of a new spinlock, resolving build errors and following maintainer feedback.
Maiquel Paiva (1):
Bluetooth: mgmt: Fix heap overflow and race condition in mesh handling
net/bluetooth/mgmt_util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH v5 1/1 Bluetooth: mgmt: Fix heap overflow and race condition in mesh handling
This patch addresses two issues in mesh handling:
1. Heap buffer overflow in mgmt_mesh_add:
The 'len' parameter wasn't being validated against the 'param' size, potentially leading to an overflow. Added a check to validate user input.
2. Race conditions in mgmt_mesh_add and mgmt_mesh_find:
These functions modify or traverse the mesh_pending list without locking. Used guard(mutex) with the existing mgmt_pending_lock to protect the critical sections, as suggested by maintainers.
--- net/bluetooth/mgmt_util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/bluetooth/mgmt_util.c +6 -2
@@ -397,8 +397,7 @@ struct mgmt_mesh_tx *mgmt_mesh_find(struct hci_dev *hdev, u8 handle) {struct mgmt_mesh_tx *mesh_tx; -if (list_empty (&hdev->mesh_pending)) -return NULL ; +guard (mutex)(&hdev->mgmt_pending_lock);list_for_each_entry (mesh_tx, &hdev->mesh_pending, list) {if (mesh_tx->handle == handle)
@@ -413,10 +412,15 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev, {struct mgmt_mesh_tx *mesh_tx; +if (len >sizeof (mesh_tx->param)) +return NULL ; + mesh_tx =kzalloc (sizeof (*mesh_tx),GFP_KERNEL );if (!mesh_tx)return NULL ; +guard (mutex)(&hdev->mgmt_pending_lock); + hdev->mesh_send_ref++;if (!hdev->mesh_send_ref) hdev->mesh_send_ref++;
Signature · 1 line
2.43.0
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/mgmt_util.c:413
error: net/bluetooth/mgmt_util.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth