Skip to content

Commit 21e4271

Browse files
hrasiqVudentz
authored andcommitted
Bluetooth: purge error queues in socket destructors
When TX timestamping is enabled via SO_TIMESTAMPING, SKBs may be queued into sk_error_queue and will stay there until consumed. If userspace never gets to read the timestamps, or if the controller is removed unexpectedly, these SKBs will leak. Fix by adding skb_queue_purge() calls for sk_error_queue in affected bluetooth destructors. RFCOMM does not currently use sk_error_queue. Fixes: 134f4b3 ("Bluetooth: add support for skb TX SND/COMPLETION timestamping") Reported-by: syzbot+7ff4013eabad1407b70a@syzkaller.appspotmail.com Closes: https://syzbot.org/bug?extid=7ff4013eabad1407b70a Cc: stable@vger.kernel.org Signed-off-by: Heitor Alves de Siqueira <halves@igalia.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent c28d2bf commit 21e4271

4 files changed

Lines changed: 4 additions & 0 deletions

File tree

net/bluetooth/hci_sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,7 @@ static void hci_sock_destruct(struct sock *sk)
21662166
mgmt_cleanup(sk);
21672167
skb_queue_purge(&sk->sk_receive_queue);
21682168
skb_queue_purge(&sk->sk_write_queue);
2169+
skb_queue_purge(&sk->sk_error_queue);
21692170
}
21702171

21712172
static const struct proto_ops hci_sock_ops = {

net/bluetooth/iso.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ static void iso_sock_destruct(struct sock *sk)
746746

747747
skb_queue_purge(&sk->sk_receive_queue);
748748
skb_queue_purge(&sk->sk_write_queue);
749+
skb_queue_purge(&sk->sk_error_queue);
749750
}
750751

751752
static void iso_sock_cleanup_listen(struct sock *parent)

net/bluetooth/l2cap_sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ static void l2cap_sock_destruct(struct sock *sk)
18171817

18181818
skb_queue_purge(&sk->sk_receive_queue);
18191819
skb_queue_purge(&sk->sk_write_queue);
1820+
skb_queue_purge(&sk->sk_error_queue);
18201821
}
18211822

18221823
static void l2cap_skb_msg_name(struct sk_buff *skb, void *msg_name,

net/bluetooth/sco.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static void sco_sock_destruct(struct sock *sk)
470470

471471
skb_queue_purge(&sk->sk_receive_queue);
472472
skb_queue_purge(&sk->sk_write_queue);
473+
skb_queue_purge(&sk->sk_error_queue);
473474
}
474475

475476
static void sco_sock_cleanup_listen(struct sock *parent)

0 commit comments

Comments
 (0)