]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.5/bluetooth-hci_uart-check-if-socket-buffer-is-err_ptr-in-h4_recv_buf.patch
Linux 4.19.32
[thirdparty/kernel/stable-queue.git] / releases / 5.0.5 / bluetooth-hci_uart-check-if-socket-buffer-is-err_ptr-in-h4_recv_buf.patch
1 From 1dc2d785156cbdc80806c32e8d2c7c735d0b4721 Mon Sep 17 00:00:00 2001
2 From: Myungho Jung <mhjungk@gmail.com>
3 Date: Tue, 22 Jan 2019 00:33:26 -0800
4 Subject: Bluetooth: hci_uart: Check if socket buffer is ERR_PTR in h4_recv_buf()
5
6 From: Myungho Jung <mhjungk@gmail.com>
7
8 commit 1dc2d785156cbdc80806c32e8d2c7c735d0b4721 upstream.
9
10 h4_recv_buf() callers store the return value to socket buffer and
11 recursively pass the buffer to h4_recv_buf() without protection. So,
12 ERR_PTR returned from h4_recv_buf() can be dereferenced, if called again
13 before setting the socket buffer to NULL from previous error. Check if
14 skb is ERR_PTR in h4_recv_buf().
15
16 Reported-by: syzbot+017a32f149406df32703@syzkaller.appspotmail.com
17 Signed-off-by: Myungho Jung <mhjungk@gmail.com>
18 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/bluetooth/h4_recv.h | 4 ++++
23 drivers/bluetooth/hci_h4.c | 4 ++++
24 2 files changed, 8 insertions(+)
25
26 --- a/drivers/bluetooth/h4_recv.h
27 +++ b/drivers/bluetooth/h4_recv.h
28 @@ -60,6 +60,10 @@ static inline struct sk_buff *h4_recv_bu
29 const struct h4_recv_pkt *pkts,
30 int pkts_count)
31 {
32 + /* Check for error from previous call */
33 + if (IS_ERR(skb))
34 + skb = NULL;
35 +
36 while (count) {
37 int i, len;
38
39 --- a/drivers/bluetooth/hci_h4.c
40 +++ b/drivers/bluetooth/hci_h4.c
41 @@ -174,6 +174,10 @@ struct sk_buff *h4_recv_buf(struct hci_d
42 struct hci_uart *hu = hci_get_drvdata(hdev);
43 u8 alignment = hu->alignment ? hu->alignment : 1;
44
45 + /* Check for error from previous call */
46 + if (IS_ERR(skb))
47 + skb = NULL;
48 +
49 while (count) {
50 int i, len;
51