lkml.org 
[lkml]   [2020]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Linux-kernel-mentees] [PATCH] net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt
Date
Fix null pointer deref in hci_phy_link_complete_evt, there was no checking there for
the hcon->amp_mgr->l2cap_conn->hconn, and also in hci_cmd_work, for
hdev->sent_cmd.

To fix this issue Add pointer checking in hci_cmd_work and
hci_phy_link_complete_evt.
[Linux-next-20200827]

Reported-by: syzbot+0bef568258653cff272f@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=0d93140da5a82305a66a136af99b088b75177b99
Signed-off-by: Anmol Karn <anmol.karan123@gmail.com>
---
net/bluetooth/hci_core.c | 4 ++++
net/bluetooth/hci_event.c | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 68bfe57b6625..533048d2a624 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -4922,6 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)

kfree_skb(hdev->sent_cmd);

+ if(hdev->sent_cmd) {
+ hdev->sent_cmd = skb_clone(skb, GFP_KERNEL);
+ }
+
hdev->sent_cmd = skb_clone(skb, GFP_KERNEL);
if (hdev->sent_cmd) {
if (hci_req_status_pend(hdev))
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4b7fc430793c..c621c8a20ea4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev,
hci_dev_unlock(hdev);
return;
}
+ if(!(hcon->amp_mgr->l2cap_conn->hcon)) {
+ hci_dev_unlock(hdev);
+ return;
+ }

bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon;

--
2.28.0
\
 
 \ /
  Last update: 2020-08-29 14:42    [W:0.037 / U:2.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site