Skip to content

Commit 1dc2d78

Browse files
myunghojholtmann
authored andcommitted
Bluetooth: hci_uart: Check if socket buffer is ERR_PTR in h4_recv_buf()
h4_recv_buf() callers store the return value to socket buffer and recursively pass the buffer to h4_recv_buf() without protection. So, ERR_PTR returned from h4_recv_buf() can be dereferenced, if called again before setting the socket buffer to NULL from previous error. Check if skb is ERR_PTR in h4_recv_buf(). Reported-by: syzbot+017a32f149406df32703@syzkaller.appspotmail.com Signed-off-by: Myungho Jung <mhjungk@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 37c589e commit 1dc2d78

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/bluetooth/h4_recv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ static inline struct sk_buff *h4_recv_buf(struct hci_dev *hdev,
6060
const struct h4_recv_pkt *pkts,
6161
int pkts_count)
6262
{
63+
/* Check for error from previous call */
64+
if (IS_ERR(skb))
65+
skb = NULL;
66+
6367
while (count) {
6468
int i, len;
6569

drivers/bluetooth/hci_h4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
174174
struct hci_uart *hu = hci_get_drvdata(hdev);
175175
u8 alignment = hu->alignment ? hu->alignment : 1;
176176

177+
/* Check for error from previous call */
178+
if (IS_ERR(skb))
179+
skb = NULL;
180+
177181
while (count) {
178182
int i, len;
179183

0 commit comments

Comments
 (0)