From: Szymon Janc <szymon.janc@codecoup.pl>
To: Chriz Chow <cmcvista@gmail.com>
Cc: marcel@holtmann.org, linux-bluetooth@vger.kernel.org,
Chriz Chow <chriz.chow@aminocom.com>
Subject: Re: [PATCH] Bluetooth: Prevent buffer overflow for large advertisement data
Date: Thu, 19 Apr 2018 14:28:52 +0200 [thread overview]
Message-ID: <1646173.KpzMEjoeCb@ix> (raw)
In-Reply-To: <1524135789-25968-1-git-send-email-chriz.chow@aminocom.com>
Hi Chriz,
On Thursday, 19 April 2018 13:03:09 CEST Chriz Chow wrote:
> In the Bluetooth Core Specifications 5.0 it has no limitation of
> the length of Advertising or Scan Response Data. Therefore,
> there are some devices sending out advertising data longer than
> HCI_MAX_AD_LENGTH, causing the buffer last_adv_data overflows.
>
> It prevents the issue by checking the data length before copying.
>
> Signed-off-by: Chriz Chow <chriz.chow@aminocom.com>
> ---
> net/bluetooth/hci_event.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 139707c..1300bb0 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1118,6 +1118,9 @@ static void store_pending_adv_report(struct hci_dev
> *hdev, bdaddr_t *bdaddr, {
> struct discovery_state *d = &hdev->discovery;
>
> + if (len > HCI_MAX_AD_LENGTH)
> + return;
> +
> bacpy(&d->last_adv_addr, bdaddr);
> d->last_adv_addr_type = bdaddr_type;
> d->last_adv_rssi = rssi;
This would indicate that controller is sending LE Advertising Report Event
with illegal length value (valid range is 0x00-0x1f). If there are such broken
controllers around we could check those but I think this should be done as
soon as possible ie. in hci_le_adv_report_evt() function.
Also, >31 bytes of advertising data is only for Extended Advertising which
would require using LE Set Extended Scan commands and would result in LE
Extended Advertising Reports being generated instead (none of those are yet
supported in kernel).
--
pozdrawiam
Szymon Janc
next prev parent reply other threads:[~2018-04-19 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 11:03 [PATCH] Bluetooth: Prevent buffer overflow for large advertisement data Chriz Chow
2018-04-19 12:28 ` Szymon Janc [this message]
2018-04-20 7:46 ` [PATCH v2] " Chriz Chow
2018-04-23 17:58 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1646173.KpzMEjoeCb@ix \
--to=szymon.janc@codecoup.pl \
--cc=chriz.chow@aminocom.com \
--cc=cmcvista@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).