All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4.14 4.9 4.4-stable] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
@ 2020-12-23 18:04 Peilin Ye
  2020-12-23 18:17 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Peilin Ye @ 2020-12-23 18:04 UTC (permalink / raw
  To: gregkh, marcel; +Cc: stable, Peilin Ye

commit f7e0e8b2f1b0a09b527885babda3e912ba820798 upstream.

`num_reports` is not being properly checked. A malformed event packet with
a large `num_reports` number makes hci_le_direct_adv_report_evt() read out
of bounds. Fix it.

Backporting notes:
  - Rebased on linux-4.14.y, commit 3f2ecb86cb90 ("Linux 4.14.212")
  - Retested by syzbot

Cc: stable@vger.kernel.org
Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events")
Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_event.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ba12bf8de826..0db218b14bf3 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -5141,20 +5141,18 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
 					 struct sk_buff *skb)
 {
 	u8 num_reports = skb->data[0];
-	void *ptr = &skb->data[1];
+	struct hci_ev_le_direct_adv_info *ev = (void *)&skb->data[1];
 
-	hci_dev_lock(hdev);
+	if (!num_reports || skb->len < num_reports * sizeof(*ev) + 1)
+		return;
 
-	while (num_reports--) {
-		struct hci_ev_le_direct_adv_info *ev = ptr;
+	hci_dev_lock(hdev);
 
+	for (; num_reports; num_reports--, ev++)
 		process_adv_report(hdev, ev->evt_type, &ev->bdaddr,
 				   ev->bdaddr_type, &ev->direct_addr,
 				   ev->direct_addr_type, ev->rssi, NULL, 0);
 
-		ptr += sizeof(*ev);
-	}
-
 	hci_dev_unlock(hdev);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 4.14 4.9 4.4-stable] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
  2020-12-23 18:04 [PATCH 4.14 4.9 4.4-stable] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Peilin Ye
@ 2020-12-23 18:17 ` Greg KH
  2020-12-23 18:38   ` Peilin Ye
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-12-23 18:17 UTC (permalink / raw
  To: Peilin Ye; +Cc: marcel, stable

On Wed, Dec 23, 2020 at 01:04:46PM -0500, Peilin Ye wrote:
> commit f7e0e8b2f1b0a09b527885babda3e912ba820798 upstream.
> 
> `num_reports` is not being properly checked. A malformed event packet with
> a large `num_reports` number makes hci_le_direct_adv_report_evt() read out
> of bounds. Fix it.
> 
> Backporting notes:
>   - Rebased on linux-4.14.y, commit 3f2ecb86cb90 ("Linux 4.14.212")
>   - Retested by syzbot
> 
> Cc: stable@vger.kernel.org
> Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events")
> Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01
> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
>  net/bluetooth/hci_event.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)

Thanks for the backport, now queued up!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4.14 4.9 4.4-stable] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt()
  2020-12-23 18:17 ` Greg KH
@ 2020-12-23 18:38   ` Peilin Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Peilin Ye @ 2020-12-23 18:38 UTC (permalink / raw
  To: Greg KH; +Cc: marcel, stable

On Wed, Dec 23, 2020 at 07:17:47PM +0100, Greg KH wrote:
> On Wed, Dec 23, 2020 at 01:04:46PM -0500, Peilin Ye wrote:
> > commit f7e0e8b2f1b0a09b527885babda3e912ba820798 upstream.
> > 
> > `num_reports` is not being properly checked. A malformed event packet with
> > a large `num_reports` number makes hci_le_direct_adv_report_evt() read out
> > of bounds. Fix it.
> > 
> > Backporting notes:
> >   - Rebased on linux-4.14.y, commit 3f2ecb86cb90 ("Linux 4.14.212")
> >   - Retested by syzbot
> > 
> > Cc: stable@vger.kernel.org
> > Fixes: 2f010b55884e ("Bluetooth: Add support for handling LE Direct Advertising Report events")
> > Reported-and-tested-by: syzbot+24ebd650e20bd263ca01@syzkaller.appspotmail.com
> > Link: https://syzkaller.appspot.com/bug?extid=24ebd650e20bd263ca01
> > Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> > ---
> >  net/bluetooth/hci_event.c | 12 +++++-------
> >  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> Thanks for the backport, now queued up!

<offlist>

No problem!  It's 24th in China - Merry Christmas!

Peilin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-23 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-23 18:04 [PATCH 4.14 4.9 4.4-stable] Bluetooth: Fix slab-out-of-bounds read in hci_le_direct_adv_report_evt() Peilin Ye
2020-12-23 18:17 ` Greg KH
2020-12-23 18:38   ` Peilin Ye

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.