Skip to contentSkip to conversation

Bluetooth: L2CAP: Send reject on command corrupted request

PATCH Applied Frédéric Danis 3 participants 3 messages Dec 8, 2023 – Dec 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: L2CAP: Send reject on command corrupted request

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.

---
 net/bluetooth/l2cap_core.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
net/bluetooth/l2cap_core.c +15 -6
index 17ca13e8c044..baeebee41cd9 100644
@@ -6492,6 +6492,14 @@ static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
 	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,
 				     struct sk_buff *skb)
 {
@@ -6517,23 +6525,24 @@ 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;
 		}
 
 		err = l2cap_bredr_sig_cmd(conn, cmd, len, skb->data);
 		if (err) {
-			struct l2cap_cmd_rej_unk rej;
-
 			BT_ERR("Wrong link type (%d)", err);
-
-			rej.reason = cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
-			l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ,
-				       sizeof(rej), &rej);
+			l2cap_sig_send_rej(conn, cmd->ident);
 		}
 
 		skb_pull(skb, len);
 	}
 
+	if (skb->len > 0) {
+		BT_DBG("corrupted command");
+		l2cap_sig_send_rej(conn, 0);
+	}
+
 drop:
 	kfree_skb(skb);
 }
Signature · 1 line
2.34.1
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=808342

---Test result---

Test Summary:

CheckPatch                    PASS      0.48 seconds
GitLint                       PASS      6.39 seconds
SubjectPrefix                 PASS      0.71 seconds
BuildKernel                   PASS      28.55 seconds
CheckAllWarning               PASS      31.37 seconds
CheckSparse                   PASS      36.94 seconds
CheckSmatch                   PASS      101.06 seconds
BuildKernel32                 PASS      27.83 seconds
TestRunnerSetup               PASS      428.07 seconds
TestRunner_l2cap-tester       PASS      23.12 seconds
TestRunner_iso-tester         PASS      48.36 seconds
TestRunner_bnep-tester        PASS      6.85 seconds
TestRunner_mgmt-tester        PASS      165.73 seconds
TestRunner_rfcomm-tester      PASS      13.37 seconds
TestRunner_sco-tester         PASS      14.52 seconds
TestRunner_ioctl-tester       PASS      12.46 seconds
TestRunner_mesh-tester        PASS      8.97 seconds
TestRunner_smp-tester         PASS      9.92 seconds
TestRunner_userchan-tester    PASS      7.43 seconds
IncrementalBuild              PASS      26.37 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Frédéric Danis
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Fri, 8 Dec 2023 18:41:50 +0100 you wrote:

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.

[...]

Here is the summary with links:
- Bluetooth: L2CAP: Send reject on command corrupted request

    https://git.kernel.org/bluetooth/bluetooth-next/c/37b85190ca1e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html