]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: L2CAP: Fix handling LE modes by L2CAP_OPTIONS
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 27 Mar 2020 18:32:14 +0000 (11:32 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 May 2021 10:05:21 +0000 (12:05 +0200)
commit b86b0b150fed840c376145383ef5105116c81b0c upstream.

L2CAP_OPTIONS shall only be used with BR/EDR modes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Zubin Mithra <zsm@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/l2cap_sock.c

index e693fee08623c3ab305ad8b9ecd6ce9ebd8fe4ce..82e76ff01267abe5f91830fbe633e00fa9e77fc9 100644 (file)
@@ -426,6 +426,20 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
                        break;
                }
 
+               /* Only BR/EDR modes are supported here */
+               switch (chan->mode) {
+               case L2CAP_MODE_BASIC:
+               case L2CAP_MODE_ERTM:
+               case L2CAP_MODE_STREAMING:
+                       break;
+               default:
+                       err = -EINVAL;
+                       break;
+               }
+
+               if (err < 0)
+                       break;
+
                memset(&opts, 0, sizeof(opts));
                opts.imtu     = chan->imtu;
                opts.omtu     = chan->omtu;
@@ -685,10 +699,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
                        break;
                }
 
-               chan->mode = opts.mode;
-               switch (chan->mode) {
-               case L2CAP_MODE_LE_FLOWCTL:
-                       break;
+               /* Only BR/EDR modes are supported here */
+               switch (opts.mode) {
                case L2CAP_MODE_BASIC:
                        clear_bit(CONF_STATE2_DEVICE, &chan->conf_state);
                        break;
@@ -702,6 +714,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
                        break;
                }
 
+               if (err < 0)
+                       break;
+
+               chan->mode = opts.mode;
                chan->imtu = opts.imtu;
                chan->omtu = opts.omtu;
                chan->fcs  = opts.fcs;