net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt
Subsystems (4)
PATCH 1/1 net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt
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]
--- net/bluetooth/hci_core.c | 4 ++++ net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+)
net/bluetooth/hci_core.c +4 -0
@@ -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))
net/bluetooth/hci_event.c +4 -0
@@ -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;
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH 1/1 net: bluetooth: Fix null pointer deref in hci_phy_link_complete_evt
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]
This patch corrected some mistakes from previous patch.
--- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +4 -1
@@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)kfree_skb (hdev->sent_cmd); - hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); +if (hdev->sent_cmd) { + hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); + } +if (hdev->sent_cmd) {if (hci_req_status_pend (hdev))hci_dev_set_flag (hdev,HCI_CMD_PENDING );
net/bluetooth/hci_event.c +4 -0
@@ -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;
Signature · 6 lines
2.28.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 9 lines · Anmol Karn
Fix null pointer deref in
hci_phy_link_complete_evt, there was no checking there for thehcon->amp_mgr->l2cap_conn->hconn, and also inhci_cmd_work, forhdev->sent_cmd.To fix this issue Add pointer checking in
hci_cmd_workandhci_phy_link_complete_evt.
[Linux-next-20200827]This patch corrected some mistakes from previous patch.
So this is a v2? That should go below the --- line, right? And you should have a v2 in the subject line like the documentation asks?
Can you redo this please?
thanks,
greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 23 lines · Anmol Karn
Fix null pointer deref in
hci_phy_link_complete_evt, there was no checking there for thehcon->amp_mgr->l2cap_conn->hconn, and also inhci_cmd_work, forhdev->sent_cmd.To fix this issue Add pointer checking in
hci_cmd_workandhci_phy_link_complete_evt.
[Linux-next-20200827]This patch corrected some mistakes from previous patch.
Reported-by [email protected]Signed-off-by Anmol Karn <[email protected]>--- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)net/bluetooth/hci_core.c +0
-0
net/bluetooth/hci_core.c static void hci_cmd_work(struct work_struct *work) · line 4927
Quoted 7 lines
net/bluetooth/hci_core.c +3
-1@@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)kfree_skb (hdev->sent_cmd); - hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); +if (hdev->sent_cmd) { + hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); + }
How can sent_cmd be NULL here? Are you sure something previous to this shouldn't be fixed instead?
Quoted 9 lines
net/bluetooth/hci_core.c +1
-0+if (hdev->sent_cmd) {if (hci_req_status_pend (hdev))hci_dev_set_flag (hdev,HCI_CMD_PENDING );net/bluetooth/hci_event.c +0
-0
net/bluetooth/hci_event.c static void hci_phy_link_complete_evt(struct hci_dev *hdev, · line 4947
Quoted 7 lines
net/bluetooth/hci_event.c +4
-0@@ -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 ; + }
How can this be triggered?
thanks,
greg k-h
Quoted 27 lines · Greg KH
Quoted 26 lines · Anmol Karn
Fix null pointer deref in
hci_phy_link_complete_evt, there was no checking there for thehcon->amp_mgr->l2cap_conn->hconn, and also inhci_cmd_work, forhdev->sent_cmd.To fix this issue Add pointer checking in
hci_cmd_workandhci_phy_link_complete_evt.
[Linux-next-20200827]This patch corrected some mistakes from previous patch.
Reported-by [email protected]Signed-off-by Anmol Karn <[email protected]>--- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)net/bluetooth/hci_core.c +0
-0@@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)kfree_skb (hdev->sent_cmd);
Quoted 7 lines
net/bluetooth/hci_core.c static void hci_cmd_work(struct work_struct *work) · line 4927
Quoted 4 lines
net/bluetooth/hci_core.c +3
-1- hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); +if (hdev->sent_cmd) { + hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); + }How can
sent_cmdbe NULL here? Are you sure something previous to this shouldn't be fixed instead?
Sir, sent_cmd was freed before this condition check, thats why i checked it,
i think i should check it before the free of hdev->sent_cmd like,
if (hdev->sent_cmd)
kfree_skb(hdev->sent_cmd);
what's your opininon on this.
Quoted 12 lines
Quoted 12 lines
net/bluetooth/hci_core.c +1
-0+if (hdev->sent_cmd) {if (hci_req_status_pend (hdev))hci_dev_set_flag (hdev,HCI_CMD_PENDING );net/bluetooth/hci_event.c +0
-0@@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev,hci_dev_unlock (hdev);
Quoted 8 lines
net/bluetooth/hci_event.c static void hci_phy_link_complete_evt(struct hci_dev *hdev, · line 4947
Quoted 6 lines
net/bluetooth/hci_event.c +4
-0return ; } +if (!(hcon->amp_mgr->l2cap_conn->hcon)) { +hci_dev_unlock (hdev); +return ; + }How can this be triggered?
syzbot showed that this line is accessed irrespective of the null value it contains, so added a pointer check for that.
please give some opinions on this,
if (!bredr_hcon) {
hci_dev_unlock(hdev);
return;
}Thanks,
Anmol Karn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 36 lines · Anmol Karn
Quoted 27 lines · Greg KH
Quoted 26 lines · Anmol Karn
Fix null pointer deref in
hci_phy_link_complete_evt, there was no checking there for thehcon->amp_mgr->l2cap_conn->hconn, and also inhci_cmd_work, forhdev->sent_cmd.To fix this issue Add pointer checking in
hci_cmd_workandhci_phy_link_complete_evt.
[Linux-next-20200827]This patch corrected some mistakes from previous patch.
Reported-by [email protected]Signed-off-by Anmol Karn <[email protected]>--- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)net/bluetooth/hci_core.c +0
-0@@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)kfree_skb (hdev->sent_cmd);Quoted 7 lines
net/bluetooth/hci_core.c static void hci_cmd_work(struct work_struct *work) · line 4927
Quoted 4 lines
net/bluetooth/hci_core.c +3
-1- hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); +if (hdev->sent_cmd) { + hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); + }How can
sent_cmdbe NULL here? Are you sure something previous to this shouldn't be fixed instead?
Quoted 1 line
Sir,
sent_cmdwas freed before this condition check, thats why i checked it,
But it can not be NULL at that point in time, as nothing set it to NULL, correct?
Quoted 4 lines
i think i should check it before the free of
hdev->sent_cmdlike,if (
hdev->sent_cmd)kfree_skb(hdev->sent_cmd);
No, that's not needed.
What is the problem with these lines that you are trying to solve?
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
net/bluetooth/hci_core.c +1
-0+if (hdev->sent_cmd) {if (hci_req_status_pend (hdev))hci_dev_set_flag (hdev,HCI_CMD_PENDING );net/bluetooth/hci_event.c +0
-0@@ -4941,6 +4941,10 @@ static void hci_phy_link_complete_evt(struct hci_dev *hdev,hci_dev_unlock (hdev);Quoted 8 lines
net/bluetooth/hci_event.c static void hci_phy_link_complete_evt(struct hci_dev *hdev, · line 4947
Quoted 6 lines
net/bluetooth/hci_event.c +4
-0return ; } +if (!(hcon->amp_mgr->l2cap_conn->hcon)) { +hci_dev_unlock (hdev); +return ; + }How can this be triggered?
Quoted 2 lines
syzbot showed that this line is accessed irrespective of the null value it contains, so added a pointer check for that.
But does hcon->amp_mgr->l2cap_conn->hcon become NULL here?
thanks,
greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 70 lines · Greg KH
Quoted 36 lines · Anmol Karn
Quoted 27 lines · Greg KH
Quoted 26 lines · Anmol Karn
Fix null pointer deref in
hci_phy_link_complete_evt, there was no checking there for thehcon->amp_mgr->l2cap_conn->hconn, and also inhci_cmd_work, forhdev->sent_cmd.To fix this issue Add pointer checking in
hci_cmd_workandhci_phy_link_complete_evt.
[Linux-next-20200827]This patch corrected some mistakes from previous patch.
Reported-by [email protected]Signed-off-by Anmol Karn <[email protected]>--- net/bluetooth/hci_core.c | 5 ++++- net/bluetooth/hci_event.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)net/bluetooth/hci_core.c +0
-0@@ -4922,7 +4922,10 @@ static void hci_cmd_work(struct work_struct *work)kfree_skb (hdev->sent_cmd);Quoted 7 lines
net/bluetooth/hci_core.c static void hci_cmd_work(struct work_struct *work) · line 4927
Quoted 4 lines
net/bluetooth/hci_core.c +3
-1- hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); +if (hdev->sent_cmd) { + hdev->sent_cmd =skb_clone (skb,GFP_KERNEL ); + }How can
sent_cmdbe NULL here? Are you sure something previous to this shouldn't be fixed instead?Quoted 1 line
Sir,
sent_cmdwas freed before this condition check, thats why i checked it,But it can not be NULL at that point in time, as nothing set it to NULL, correct?
Quoted 4 lines
i think i should check it before the free of
hdev->sent_cmdlike,if (
hdev->sent_cmd)kfree_skb(hdev->sent_cmd);No, that's not needed.
What is the problem with these lines that you are trying to solve?
Quoted 19 lines
Quoted 18 lines
Quoted 9 lines
net/bluetooth/hci_core.c +1
-0+if (hdev->sent_cmd) {if (hci_req_status_pend (hdev))hci_dev_set_flag (hdev,HCI_CMD_PENDING );net/bluetooth/hci_event.c +0
-0net/bluetooth/hci_event.c static void hci_phy_link_complete_evt(struct hci_dev *hdev, · line 4947
Quoted 7 lines
net/bluetooth/hci_event.c +4
-0@@ -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 ; + }How can this be triggered?
Quoted 4 lines
Quoted 2 lines
syzbot showed that this line is accessed irrespective of the null value it contains, so added a pointer check for that.
But does
hcon->amp_mgr->l2cap_conn->hconbecome NULL here?
Sir, according to the report obtained by running decode_stacktrace on logs there is something getting null at this line, after verifying the buggy address i thought it would be better to check this whole line.
will dig more deeper into this and will make appropriate changes in the next version, thanks for review.
Anmol Karn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees