Bluetooth: L2CAP: Send reject on command corrupted request
commit 78b99eb1faa7371bf9c534690f26a71b6996622d upstream. L2CAP/COS/CED/BI-02-C PTS test send a malformed L2CAP signaling packet with 2 commands in it (a connection request and an unknown command) and expect to get a connection response packet and a command reject packet. The second is currently not sent. Cc: stable@vger.kernel.org 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
70db6466c0
Коммит
916ca52a3e
|
@ -6493,6 +6493,14 @@ drop:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void l2cap_sig_send_rej(struct l2cap_conn *conn, u16 ident)
|
||||||
|
{
|
||||||
|
struct l2cap_cmd_rej_unk rej;
|
||||||
|
|
||||||
|
rej.reason = cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
||||||
|
l2cap_send_cmd(conn, ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
|
@ -6518,23 +6526,24 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
||||||
|
|
||||||
if (len > skb->len || !cmd->ident) {
|
if (len > skb->len || !cmd->ident) {
|
||||||
BT_DBG("corrupted command");
|
BT_DBG("corrupted command");
|
||||||
|
l2cap_sig_send_rej(conn, cmd->ident);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = l2cap_bredr_sig_cmd(conn, cmd, len, skb->data);
|
err = l2cap_bredr_sig_cmd(conn, cmd, len, skb->data);
|
||||||
if (err) {
|
if (err) {
|
||||||
struct l2cap_cmd_rej_unk rej;
|
|
||||||
|
|
||||||
BT_ERR("Wrong link type (%d)", err);
|
BT_ERR("Wrong link type (%d)", err);
|
||||||
|
l2cap_sig_send_rej(conn, cmd->ident);
|
||||||
rej.reason = cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
|
||||||
l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ,
|
|
||||||
sizeof(rej), &rej);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
skb_pull(skb, len);
|
skb_pull(skb, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skb->len > 0) {
|
||||||
|
BT_DBG("corrupted command");
|
||||||
|
l2cap_sig_send_rej(conn, 0);
|
||||||
|
}
|
||||||
|
|
||||||
drop:
|
drop:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче