Skip to contentSkip to conversation

shared/bap: Don't fail an ASE CP write with an unknown opcode

PATCH Applied Simon Mikuda 3 participants 4 messages Nov 24 – Nov 25 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 shared/bap: Don't fail an ASE CP write with an unknown opcode

A write of an unknown opcode to the ASE Control Point is answered with an Unsupported Opcode notification, but the write itself still fails with Request Not Supported, as ret keeps its initial value. The other Control Point errors, such as a truncated or zero ASEs write, are only reported in the notification and the write succeeds, so do the same for an unknown opcode.

Fixes b798cec4ca62 ("shared/bap: Add initial code for handling BAP")
Assisted-by Claude:claude-opus-5-5
---
 src/shared/bap.c | 1 +
 1 file changed, 1 insertion(+)
src/shared/bap.c +1 -0
index 8fc28de52..e17e9cb60 100644
@@ -4171,6 +4171,7 @@ static void ascs_ase_cp_write(struct gatt_db_attribute *attrib,
 	} else {
 		DBG(bap, "Unknown opcode 0x%02x", hdr->op);
 		ascs_ase_rsp_add_errno(rsp, 0x00, -ENOTSUP);
+		ret = 0;
 	}
 
 respond:

base-commit: 1608f836188610aabeff5a3164169ebe0360e443

Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 unit/test-bap: Add test for an unknown ASE CP opcode

Write an unknown opcode to the ASE Control Point with a Write Request and expect the Unsupported Opcode notification and a Write Response.

Assisted-by Claude:claude-opus-5-5
---
 unit/test-bap.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
unit/test-bap.c +24 -0
index bfe98a885..7c5f94d86 100644
@@ -4624,6 +4624,26 @@ static void test_scc_metadata(void)
 	IOV_DATA(0x52, CP_HND, _op, 0x00), \
 	ASE_CP_RSP_TRUNCATED(_op)
 
+/* ATT: Write Request (0x12) len 5
+ *   Handle: 0x0022 Type: ASE Control Point (0x2bc6)
+ *     Data: 0f0101
+ * ATT: Write Response (0x13) len 0
+ * ATT: Handle Value Notification (0x1b) len 7
+ *   Handle: 0x0022 Type: ASE Control Point (0x2bc6)
+ *     Data: 0fff000100
+ *       Opcode: Unknown (0x0f)
+ *       Number of ASE(s): 255
+ *       ASE: #0
+ *       ASE ID: 0x00
+ *       ASE Response Code: Unsupported Opcode (0x01)
+ *       ASE Response Reason: None (0x00)
+ */
+#define SPE_CP_UNSUPPORTED(_op) \
+	IOV_DATA(0x12, CP_HND, _op, 0x01, 0x01), \
+	IOV_DATA(0x13), \
+	IOV_NULL, \
+	IOV_DATA(0x1b, CP_HND, _op, 0xff, 0x00, 0x01, 0x00)
+
 #define SPE_METADATA_TRUNCATED(_ase) \
 	IOV_DATA(0x52, CP_HND, 0x07, 0x01, _ase), \
 	ASE_CP_RSP_TRUNCATED(0x07)
@@ -4657,6 +4677,10 @@ static void test_usr_spe(void)
 	define_test("BAP/USR/SPE/BI-02-C [USR ASE Control Point zero ASEs]",
 			test_setup_server, test_server, NULL,
 			SPE_CP_ZERO_ASES(0x03));
+	define_test("BAP/USR/SPE/BLUEZ-1 [USR ASE Control Point unsupported "
+			"opcode]",
+			test_setup_server, test_server, NULL,
+			SPE_CP_UNSUPPORTED(0x0f));
 	define_test("BAP/USR/SPE/BI-03-C [USR Update Metadata truncated]",
 			test_setup_server, test_server, NULL,
 			SPE_METADATA_TRUNCATED(SRC_ID(0)));
Signature · 1 line
2.43.0
#2 lore raw
In reply to Simon Mikuda

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/series/1220883/

---Test result---

Test Summary:

CheckPatch                    PASS      0.68 seconds
GitLint                       PASS      0.52 seconds
BuildEll                      PASS      14.84 seconds
BluezMake                     PASS      195.72 seconds
MakeCheck                     PASS      12.99 seconds
MakeDistcheck                 PASS      102.22 seconds
CheckValgrind                 PASS      230.92 seconds
CheckSmatch                   WARNING   179.28 seconds
bluezmakeextell               PASS      61.28 seconds
TestFunctional                PASS      911.65 seconds
IncrementalBuild              PASS      208.51 seconds
ScanBuild                     PASS      601.64 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures

https://github.com/bluez/bluez/pull/2902

---
Regards,
Linux Bluetooth

#3 lore raw
In reply to Simon Mikuda
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 24 Nov 2026 14:31:11 +0100 you wrote:

A write of an unknown opcode to the ASE Control Point is answered with an Unsupported Opcode notification, but the write itself still fails with Request Not Supported, as ret keeps its initial value. The other Control Point errors, such as a truncated or zero ASEs write, are only reported in the notification and the write succeeds, so do the same for an unknown opcode.

[...]

Here is the summary with links:
- [BlueZ,1/2] shared/bap: Don't fail an ASE CP write with an unknown opcode

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0fd6851e16b1
  - [BlueZ,2/2] unit/test-bap: Add test for an unknown ASE CP opcode
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0dc9b0db1fe6

You are awesome, thank you!

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