]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: L2CAP: Fix possible multiple reject send
authorFrédéric Danis <frederic.danis@collabora.com>
Tue, 19 Dec 2023 08:10:22 +0000 (09:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 07:42:10 +0000 (08:42 +0100)
[ Upstream commit 96a3398b467ab8aada3df2f3a79f4b7835d068b8 ]

In case of an incomplete command or a command with a null identifier 2
reject packets will be sent, one with the identifier and one with 0.
Consuming the data of the command will prevent it.
This allows to send a reject packet for each corrupted command in a
multi-command packet.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/l2cap_core.c

index cf78a48085eda6623cfb6be38e5559f3216fe2aa..a752032e12fcfd201fadf65e1c25dc39da88a0db 100644 (file)
@@ -6522,7 +6522,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
                if (len > skb->len || !cmd->ident) {
                        BT_DBG("corrupted command");
                        l2cap_sig_send_rej(conn, cmd->ident);
-                       break;
+                       skb_pull(skb, len > skb->len ? skb->len : len);
+                       continue;
                }
 
                err = l2cap_bredr_sig_cmd(conn, cmd, len, skb->data);