From: Marcel Holtmann <marcel@holtmann.org>
To: Mat Martineau <mathewm@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org, padovan@profusion.mobi,
pkrystad@codeaurora.org
Subject: Re: [PATCH 2/2] Bluetooth: Prevent uninitialized data access in L2CAP configuration
Date: Thu, 08 Dec 2011 10:29:39 +0200 [thread overview]
Message-ID: <1323332979.1965.19.camel@aeonflux> (raw)
In-Reply-To: <1323217407-2490-3-git-send-email-mathewm@codeaurora.org>
Hi Mat,
> When configuring an ERTM or streaming mode connection, remote devices
> are expected to send an RFC option in a successful config response. A
> misbehaving remote device might not send an RFC option, and the L2CAP
> code should not access uninitialized data in this case.
>
> Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
> ---
> net/bluetooth/l2cap_core.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 5ea94a1..49ae7df 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -2152,7 +2152,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
> void *ptr = req->data;
> int type, olen;
> unsigned long val;
> - struct l2cap_conf_rfc rfc;
> + struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
>
> BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
>
> @@ -2205,6 +2205,9 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
> break;
> case L2CAP_MODE_STREAMING:
> chan->mps = le16_to_cpu(rfc.max_pdu_size);
> + break;
> + default:
> + break;
Adding a BT_ERR here would be a good idea.
> }
> }
>
> @@ -2271,6 +2274,14 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
> }
> }
>
> + /* Use sane default values in case a misbehaving remote device
> + * did not send an RFC option.
> + */
> + rfc.mode = chan->mode;
> + rfc.retrans_timeout = cpu_to_le16(chan->retrans_timeout);
> + rfc.monitor_timeout = cpu_to_le16(chan->monitor_timeout);
> + rfc.max_pdu_size = cpu_to_le16(chan->mps);
> +
> done:
> switch (rfc.mode) {
> case L2CAP_MODE_ERTM:
> @@ -2280,6 +2291,9 @@ done:
> break;
> case L2CAP_MODE_STREAMING:
> chan->mps = le16_to_cpu(rfc.max_pdu_size);
> + break;
> + default:
> + break;
Also adding a BT_ERR seems like the right thing to do.
Otherwise patch looks good to me.
Regards
Marcel
next prev parent reply other threads:[~2011-12-08 8:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 0:23 [PATCH 0/2] Bug fixes for RFCOMM and L2CAP Mat Martineau
2011-12-07 0:23 ` [PATCH 1/2] Bluetooth: Clear RFCOMM session timer when disconnecting last channel Mat Martineau
2011-12-08 8:25 ` Marcel Holtmann
2011-12-08 16:57 ` Mat Martineau
2011-12-08 22:13 ` Marcel Holtmann
2011-12-07 0:23 ` [PATCH 2/2] Bluetooth: Prevent uninitialized data access in L2CAP configuration Mat Martineau
2011-12-08 8:29 ` Marcel Holtmann [this message]
2011-12-08 21:32 ` Mat Martineau
2011-12-16 23:58 ` [PATCH 0/2] Bug fixes for RFCOMM and L2CAP Mat Martineau
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=1323332979.1965.19.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mathewm@codeaurora.org \
--cc=padovan@profusion.mobi \
--cc=pkrystad@codeaurora.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).