Commit 4e6a2c5b authored by Hyunwoo Kim's avatar Hyunwoo Kim Committed by Ziyang Xuan
Browse files

Bluetooth: af_bluetooth: Fix Use-After-Free in bt_sock_recvmsg

mainline inclusion
from mainline-v6.7-rc7
commit 2e07e8348ea454615e268222ae3fc240421be768
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8RXOD
CVE: CVE-2023-51779

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=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: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: default avatarHyunwoo Kim <v4bel@theori.io>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Conflicts:
	net/bluetooth/af_bluetooth.c
Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
parent d09efbc6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment