Skip to content

Commit e305509

Browse files
f0rm2l1nholtmann
authored andcommitted
Bluetooth: use correct lock to prevent UAF of hdev object
The hci_sock_dev_event() function will cleanup the hdev object for sockets even if this object may still be in used within the hci_sock_bound_ioctl() function, result in UAF vulnerability. This patch replace the BH context lock to serialize these affairs and prevent the race condition. Signed-off-by: Lin Ma <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 6a137ca commit e305509

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bluetooth/hci_sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
762762
/* Detach sockets from device */
763763
read_lock(&hci_sk_list.lock);
764764
sk_for_each(sk, &hci_sk_list.head) {
765-
bh_lock_sock_nested(sk);
765+
lock_sock(sk);
766766
if (hci_pi(sk)->hdev == hdev) {
767767
hci_pi(sk)->hdev = NULL;
768768
sk->sk_err = EPIPE;
@@ -771,7 +771,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
771771

772772
hci_dev_put(hdev);
773773
}
774-
bh_unlock_sock(sk);
774+
release_sock(sk);
775775
}
776776
read_unlock(&hci_sk_list.lock);
777777
}

0 commit comments

Comments
 (0)