Skip to content

Commit

Permalink
Bluetooth: Fix endianness issue with L2CAP MPS configuration
Browse files Browse the repository at this point in the history
Incoming configuration values must be converted to native CPU order
before use.  This fixes a bug where a little-endian MPS value is
compared to a native CPU value.  On big-endian processors, this
can cause ERTM and streaming mode segmentation to produce PDUs
that are larger than the remote stack is expecting, or that would
produce fragmented skbs that the current FCS code cannot handle.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Mat Martineau authored and Marcel Holtmann committed Aug 10, 2010
1 parent c4e9b56 commit 86b1b26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/bluetooth/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2705,8 +2705,9 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data)
case L2CAP_MODE_ERTM:
pi->remote_tx_win = rfc.txwin_size;
pi->remote_max_tx = rfc.max_transmit;
if (rfc.max_pdu_size > pi->conn->mtu - 10)
rfc.max_pdu_size = le16_to_cpu(pi->conn->mtu - 10);

if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10);

pi->remote_mps = le16_to_cpu(rfc.max_pdu_size);

Expand All @@ -2723,8 +2724,8 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data)
break;

case L2CAP_MODE_STREAMING:
if (rfc.max_pdu_size > pi->conn->mtu - 10)
rfc.max_pdu_size = le16_to_cpu(pi->conn->mtu - 10);
if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10);

pi->remote_mps = le16_to_cpu(rfc.max_pdu_size);

Expand Down

0 comments on commit 86b1b26

Please sign in to comment.