Skip to content

Commit a8d1d73

Browse files
committed
Bluetooth: L2CAP: Fix not checking output MTU is acceptable on L2CAP_ECRED_CONN_REQ
Upon receiving L2CAP_ECRED_CONN_REQ the given MTU shall be checked against the suggested MTU of the listening socket as that is required by the likes of PTS L2CAP/ECFC/BV-27-C test which expects L2CAP_CR_LE_UNACCEPT_PARAMS if the MTU is lowers than socket omtu. In order to be able to set chan->omtu the code now allows setting setsockopt(BT_SNDMTU), but it is only allowed when connection has not been stablished since there is no procedure to reconfigure the output MTU. Link: bluez/bluez#1895 Fixes: 15f02b9 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 7cff9a4 commit a8d1d73

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

net/bluetooth/l2cap_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,6 +5117,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
51175117
goto unlock;
51185118
}
51195119

5120+
/* Check if the listening channel has set an output MTU then the
5121+
* requested MTU shall be less than or equal to that value.
5122+
*/
5123+
if (pchan->omtu && mtu < pchan->omtu) {
5124+
result = L2CAP_CR_LE_UNACCEPT_PARAMS;
5125+
goto unlock;
5126+
}
5127+
51205128
result = L2CAP_CR_LE_SUCCESS;
51215129

51225130
for (i = 0; i < num_scid; i++) {

net/bluetooth/l2cap_sock.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,10 +1029,17 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
10291029
break;
10301030
}
10311031

1032-
/* Setting is not supported as it's the remote side that
1033-
* decides this.
1034-
*/
1035-
err = -EPERM;
1032+
/* Only allow setting output MTU when not connected */
1033+
if (sk->sk_state == BT_CONNECTED) {
1034+
err = -EISCONN;
1035+
break;
1036+
}
1037+
1038+
err = copy_safe_from_sockptr(&mtu, sizeof(mtu), optval, optlen);
1039+
if (err)
1040+
break;
1041+
1042+
chan->omtu = mtu;
10361043
break;
10371044

10381045
case BT_RCVMTU:

0 commit comments

Comments
 (0)