Skip to content

Commit e14a7eb

Browse files
fdanis-ossgregkh
authored andcommitted
Bluetooth: L2CAP: Send reject on command corrupted request
commit 78b99eb 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: [email protected] Signed-off-by: Frédéric Danis <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 37f71e2 commit e14a7eb

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6493,6 +6493,14 @@ static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
64936493
kfree_skb(skb);
64946494
}
64956495

6496+
static inline void l2cap_sig_send_rej(struct l2cap_conn *conn, u16 ident)
6497+
{
6498+
struct l2cap_cmd_rej_unk rej;
6499+
6500+
rej.reason = cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
6501+
l2cap_send_cmd(conn, ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
6502+
}
6503+
64966504
static inline void l2cap_sig_channel(struct l2cap_conn *conn,
64976505
struct sk_buff *skb)
64986506
{
@@ -6518,23 +6526,24 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
65186526

65196527
if (len > skb->len || !cmd->ident) {
65206528
BT_DBG("corrupted command");
6529+
l2cap_sig_send_rej(conn, cmd->ident);
65216530
break;
65226531
}
65236532

65246533
err = l2cap_bredr_sig_cmd(conn, cmd, len, skb->data);
65256534
if (err) {
6526-
struct l2cap_cmd_rej_unk rej;
6527-
65286535
BT_ERR("Wrong link type (%d)", err);
6529-
6530-
rej.reason = cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
6531-
l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ,
6532-
sizeof(rej), &rej);
6536+
l2cap_sig_send_rej(conn, cmd->ident);
65336537
}
65346538

65356539
skb_pull(skb, len);
65366540
}
65376541

6542+
if (skb->len > 0) {
6543+
BT_DBG("corrupted command");
6544+
l2cap_sig_send_rej(conn, 0);
6545+
}
6546+
65386547
drop:
65396548
kfree_skb(skb);
65406549
}

0 commit comments

Comments
 (0)