Skip to content

Commit

Permalink
Bluetooth: Prevent uninitialized data access in L2CAP configuration
Browse files Browse the repository at this point in the history
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>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Mat Martineau authored and Gustavo F. Padovan committed Dec 19, 2011
1 parent 33cb722 commit 36e999a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -2271,6 +2271,16 @@ 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(L2CAP_DEFAULT_RETRANS_TO);
rfc.monitor_timeout = cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO);
rfc.max_pdu_size = cpu_to_le16(chan->imtu);

BT_ERR("Expected RFC option was not found, using defaults");

done:
switch (rfc.mode) {
case L2CAP_MODE_ERTM:
Expand Down

0 comments on commit 36e999a

Please sign in to comment.