]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: L2CAP: accept zero as a special value for MTU auto-selection
authorFedor Pchelkin <pchelkin@ispras.ru>
Tue, 28 Jan 2025 21:08:14 +0000 (00:08 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 29 Jan 2025 20:29:41 +0000 (15:29 -0500)
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>
net/bluetooth/l2cap_sock.c

index 49f97d4138ea71eb7163dda32842732fc39954b7..46ea0bee2259f88513ed3e4a3d42e6805243c30e 100644 (file)
@@ -710,12 +710,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;
        }