From: Gustavo Padovan <padovan@profusion.mobi>
To: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 5/5] Bluetooth: Correct packet len calculation
Date: Tue, 20 Dec 2011 17:05:04 -0200 [thread overview]
Message-ID: <20111220190504.GA24612@joana> (raw)
In-Reply-To: <1324305091-19393-6-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-12-19 16:31:31 +0200]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Remove unneeded skb_pull and correct packet length calculation
> removing magic number. Move BT_DBG after len check otherwise
> it could possibly access wrong memory.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/hci_event.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 919e3c0..47e1476 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2266,20 +2266,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
> struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
> int i;
>
> - skb_pull(skb, sizeof(*ev));
> -
> - BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
> -
> if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
> BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode);
> return;
> }
>
> - if (skb->len < ev->num_hndl * 4) {
> + if (skb->len < sizeof(*ev) || skb->len < sizeof(*ev) +
> + ev->num_hndl * sizeof(struct hci_comp_pkts_info)) {
I think you can remove the first part of this check.
Gustavo
next prev parent reply other threads:[~2011-12-20 19:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 14:31 [PATCHv3 0/5] Rebased AMP initialization patches Emeltchenko Andrei
2011-12-19 14:31 ` [PATCHv3 1/5] Bluetooth: Split ctrl init to BREDR and AMP parts Emeltchenko Andrei
2011-12-19 14:31 ` [PATCHv3 2/5] Bluetooth: Initialize default flow control mode Emeltchenko Andrei
2011-12-19 14:31 ` [PATCHv3 3/5] Bluetooth: Check for " Emeltchenko Andrei
2011-12-19 14:31 ` [PATCHv3 4/5] Bluetooth: Clean up magic pointers Emeltchenko Andrei
2011-12-20 19:05 ` Gustavo Padovan
2011-12-19 14:31 ` [PATCHv3 5/5] Bluetooth: Correct packet len calculation Emeltchenko Andrei
2011-12-19 15:33 ` Marcel Holtmann
2011-12-20 19:05 ` Gustavo Padovan [this message]
2011-12-20 21:02 ` Marcel Holtmann
2011-12-30 10:11 ` Emeltchenko Andrei
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=20111220190504.GA24612@joana \
--to=padovan@profusion.mobi \
--cc=Andrei.Emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.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