net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
Subsystems (4)
PATCH 1/1 net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
Check upon num_rsp is insufficient. A malformed event packet with a large num_rsp number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it. Also, make num_rsp unsigned.
This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2
--- net/bluetooth/hci_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/hci_event.c +3 -3
@@ -4369,13 +4369,13 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) {struct inquiry_data data; -struct extended_inquiry_info *info = (void *) (skb->data +1 ); -int num_rsp = *((__u8 *) skb->data); +struct extended_inquiry_info *info = (void *)(skb->data +1 ); +__u8 num_rsp = *((__u8 *)skb->data);size_t eir_len;BT_DBG ("%s num_rsp %d" , hdev->name, num_rsp); -if (!num_rsp) +if (!num_rsp || num_rsp *sizeof (*info) > skb->truesize)return ;if (hci_dev_test_flag (hdev,HCI_PERIODIC_INQ ))
Signature · 1 line
2.25.1
PATCH v2 1/1 net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
Check upon num_rsp is insufficient. A malformed event packet with a large num_rsp number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it.
This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2
---
Changes in v2:
- Use skb->len instead of skb->truesize as the length limit.
- Leave num_rsp as of type int.
net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_event.c +1 -1
@@ -4375,7 +4375,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,BT_DBG ("%s num_rsp %d" , hdev->name, num_rsp); -if (!num_rsp) +if (!num_rsp || skb->len < num_rsp *sizeof (*info))return ;if (hci_dev_test_flag (hdev,HCI_PERIODIC_INQ ))
Signature · 1 line
2.25.1
Quoted 10 lines · Peilin Ye
Check upon
num_rspis insufficient. A malformed event packet with a largenum_rspnumber makeshci_extended_inquiry_result_evt()go out of bounds. Fix it.This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2Reported-by [email protected]Signed-off-by Peilin Ye <[email protected]>
Bluetooth maintainers, can you also add a cc: stable on this so it gets picked up properly there?
thanks,
greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH v3 1/1 net/bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt()
In reply to Peilin YeCheck upon num_rsp is insufficient. A malformed event packet with a large num_rsp number makes hci_extended_inquiry_result_evt() go out of bounds. Fix it.
This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2
---
Change in v3:
- Minimum skb->len requirement was 1 byte inaccurate since info starts from skb->data + 1. Fix it.
Changes in v2:
- Use skb->len instead of skb->truesize as the length limit.
- Leave num_rsp as of type int.
net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_event.c +1 -1
@@ -4375,7 +4375,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,BT_DBG ("%s num_rsp %d" , hdev->name, num_rsp); -if (!num_rsp) +if (!num_rsp || skb->len < num_rsp *sizeof (*info) +1 )return ;if (hci_dev_test_flag (hdev,HCI_PERIODIC_INQ ))
Signature · 6 lines
2.25.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Marcel Holtmann
maintainerHi Peilin,
Quoted 14 lines
Check upon
num_rspis insufficient. A malformed event packet with a largenum_rspnumber makeshci_extended_inquiry_result_evt()go out of bounds. Fix it.This patch fixes the following syzbot bug:
https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2---
Change in v3:
- Minimumskb->lenrequirement was 1 byte inaccurate sinceinfo
Quoted 8 lines
starts from `skb->data + 1`. Fix it.Changes in v2:
- Useskb->leninstead ofskb->truesizeas the length limit.
- Leavenum_rspas of typeint.
net/bluetooth/hci_event.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Re: maybe similar bug exists for HCI_EV_INQUIRY_RESULT* like [Linux-kernel-mentees] [PATCH v2] net/bluetooth: slab-out-of-bounds read in hci_extended_inquiry_result_evt()
In reply to Peilin YeFor the net/bluetooth/hci_event.c , maybe similar bug could be inside hci_inquiry_result_with_rssi_evt() that is HCI_EV_INQUIRY_RESULT_WITH_RSSI and inside hci_inquiry_result_evt() that is HCI_EV_INQUIRY_RESULT.
Re: maybe similar bug exists for HCI_EV_INQUIRY_RESULT* like [Linux-kernel-mentees] [PATCH v2] net/bluetooth: slab-out-of-bounds read in hci_extended_inquiry_result_evt()
Quoted 3 lines · Alexander Larkin
For the
net/bluetooth/hci_event.c, maybe similar bug could be insidehci_inquiry_result_with_rssi_evt()that isHCI_EV_INQUIRY_RESULT_WITH_RSSIand insidehci_inquiry_result_evt()that isHCI_EV_INQUIRY_RESULT.
Hi Alexander,
Thanks for looking into this, I believe they were handled in commit 629b49c848ee ("Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()") and commit 75bbd2ea50ba ("Bluetooth:
Prevent out-of-bounds read in hci_inquiry_result_evt()").
Thanks,
Peilin Ye