summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedor Pchelkin <pchelkin@ispras.ru>2025-01-29 00:08:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-17 09:40:18 +0100
commitaa91d54016141d0a141f486ae498549023677ee8 (patch)
tree28de9bce389553fffbd398f38dd7420ce2424d1a
parent245d48c1ba3e7a1779c2f4cbc6f581ddc8a78e22 (diff)
downloadlinux-aa91d54016141d0a141f486ae498549023677ee8.tar.gz
linux-aa91d54016141d0a141f486ae498549023677ee8.tar.bz2
linux-aa91d54016141d0a141f486ae498549023677ee8.zip
Bluetooth: L2CAP: accept zero as a special value for MTU auto-selection
commit 5c61419e02033eaf01733d66e2fcd4044808f482 upstream. One of the possible ways to enable the input MTU auto-selection for L2CAP connections is supposed to be through passing a special "0" value for it as a socket option. Commit [1] added one of those into avdtp. However, it simply wouldn't work because the kernel still treats the specified value as invalid and denies the setting attempt. Recorded BlueZ logs include the following: bluetoothd[496]: profiles/audio/avdtp.c:l2cap_connect() setsockopt(L2CAP_OPTIONS): Invalid argument (22) [1]: https://github.com/bluez/bluez/commit/ae5be371a9f53fed33d2b34748a95a5498fd4b77 Found by Linux Verification Center (linuxtesting.org). Fixes: 4b6e228e297b ("Bluetooth: Auto tune if input MTU is set to 0") Cc: stable@vger.kernel.org Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/bluetooth/l2cap_sock.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 57ea1b3ae35a..3451c64fc42d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -709,12 +709,12 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
{
switch (chan->scid) {
case L2CAP_CID_ATT:
- if (mtu < L2CAP_LE_MIN_MTU)
+ if (mtu && mtu < L2CAP_LE_MIN_MTU)
return false;
break;
default:
- if (mtu < L2CAP_DEFAULT_MIN_MTU)
+ if (mtu && mtu < L2CAP_DEFAULT_MIN_MTU)
return false;
}