]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: af_bluetooth: Fix Use-After-Free in bt_sock_recvmsg
authorHyunwoo Kim <v4bel@theori.io>
Sat, 9 Dec 2023 10:55:18 +0000 (05:55 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 14:13:39 +0000 (15:13 +0100)
commit2b16d960c79abc397f102c3d23d30005b68cb036
tree39e8d3e8b218fd6053bf06aa94b11d82db9a27e8
parentded3cfdefec8b2accc767f176419316b61c157c3
Bluetooth: af_bluetooth: Fix Use-After-Free in bt_sock_recvmsg

[ Upstream commit 2e07e8348ea454615e268222ae3fc240421be768 ]

This can cause a race with bt_sock_ioctl() because
bt_sock_recvmsg() gets the skb from sk->sk_receive_queue
and then frees it without holding lock_sock.
A use-after-free for a skb occurs with the following flow.
```
bt_sock_recvmsg() -> skb_recv_datagram() -> skb_free_datagram()
bt_sock_ioctl() -> skb_peek()
```
Add lock_sock to bt_sock_recvmsg() to fix this issue.

Cc: stable@vger.kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/af_bluetooth.c