public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices
@ 2026-03-24  2:04 Pengpeng Hou
  2026-03-24  4:17 ` bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pengpeng Hou @ 2026-03-24  2:04 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, pengpeng

btusb_work() maps the number of active SCO links to USB alternate
settings through a three-entry lookup table when CVSD traffic uses
transparent voice settings. The lookup currently indexes alts[] with
data->sco_num - 1 without first constraining sco_num to the number of
available table entries.

While the table only defines alternate settings for up to three SCO
links, data->sco_num comes from hci_conn_num() and is used directly.
Cap the lookup to the last table entry before indexing it so the
driver keeps selecting the highest supported alternate setting without
reading past alts[].

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/bluetooth/btusb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a1c5eb993e47..870a6aa92216 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2376,8 +2376,11 @@ static void btusb_work(struct work_struct *work)
 		if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) {
 			if (hdev->voice_setting & 0x0020) {
 				static const int alts[3] = { 2, 4, 5 };
+				unsigned int sco_idx;
 
-				new_alts = alts[data->sco_num - 1];
+				sco_idx = min_t(unsigned int, data->sco_num,
+						ARRAY_SIZE(alts)) - 1;
+				new_alts = alts[sco_idx];
 			} else {
 				new_alts = data->sco_num;
 			}
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: Bluetooth: btusb: clamp SCO altsetting table indices
  2026-03-24  2:04 [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices Pengpeng Hou
@ 2026-03-24  4:17 ` bluez.test.bot
  2026-03-24 19:58 ` [PATCH] " Luiz Augusto von Dentz
  2026-03-25  0:42 ` [PATCH v2] " Pengpeng Hou
  2 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-03-24  4:17 UTC (permalink / raw)
  To: linux-bluetooth, pengpeng

[-- Attachment #1: Type: text/plain, Size: 2833 bytes --]

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=1071323

---Test result---

Test Summary:
CheckPatch                    PENDING   0.44 seconds
GitLint                       PENDING   0.29 seconds
SubjectPrefix                 PASS      0.08 seconds
BuildKernel                   PASS      24.43 seconds
CheckAllWarning               PASS      26.93 seconds
CheckSparse                   PASS      25.70 seconds
BuildKernel32                 PASS      23.78 seconds
TestRunnerSetup               PASS      528.00 seconds
TestRunner_l2cap-tester       PASS      28.35 seconds
TestRunner_iso-tester         FAIL      34.42 seconds
TestRunner_bnep-tester        PASS      6.23 seconds
TestRunner_mgmt-tester        FAIL      112.30 seconds
TestRunner_rfcomm-tester      PASS      9.33 seconds
TestRunner_sco-tester         FAIL      14.34 seconds
TestRunner_ioctl-tester       PASS      10.28 seconds
TestRunner_mesh-tester        FAIL      11.50 seconds
TestRunner_smp-tester         PASS      8.56 seconds
TestRunner_userchan-tester    PASS      6.60 seconds
IncrementalBuild              PENDING   0.89 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0
Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.106 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    1.812 seconds
Mesh - Send cancel - 2                               Timed out    1.995 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices
  2026-03-24  2:04 [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices Pengpeng Hou
  2026-03-24  4:17 ` bluez.test.bot
@ 2026-03-24 19:58 ` Luiz Augusto von Dentz
  2026-03-25  0:42 ` [PATCH v2] " Pengpeng Hou
  2 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-03-24 19:58 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: Marcel Holtmann, linux-bluetooth, linux-kernel

Hi,

On Mon, Mar 23, 2026 at 10:05 PM Pengpeng Hou <pengpeng@iscas.ac.cn> wrote:
>
> btusb_work() maps the number of active SCO links to USB alternate
> settings through a three-entry lookup table when CVSD traffic uses
> transparent voice settings. The lookup currently indexes alts[] with
> data->sco_num - 1 without first constraining sco_num to the number of
> available table entries.
>
> While the table only defines alternate settings for up to three SCO
> links, data->sco_num comes from hci_conn_num() and is used directly.
> Cap the lookup to the last table entry before indexing it so the
> driver keeps selecting the highest supported alternate setting without
> reading past alts[].
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>  drivers/bluetooth/btusb.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index a1c5eb993e47..870a6aa92216 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -2376,8 +2376,11 @@ static void btusb_work(struct work_struct *work)
>                 if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) {
>                         if (hdev->voice_setting & 0x0020) {
>                                 static const int alts[3] = { 2, 4, 5 };
> +                               unsigned int sco_idx;
>
> -                               new_alts = alts[data->sco_num - 1];
> +                               sco_idx = min_t(unsigned int, data->sco_num,
> +                                               ARRAY_SIZE(alts)) - 1;
> +                               new_alts = alts[sco_idx];
>                         } else {
>                                 new_alts = data->sco_num;
>                         }
> --
> 2.50.1 (Apple Git-155)

https://sashiko.dev/#/patchset/20260324020427.60125-1-pengpeng%40iscas.ac.cn

They seem valid to me, so we might need to check if sco_idx is looping
around, etc.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] Bluetooth: btusb: clamp SCO altsetting table indices
  2026-03-24  2:04 [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices Pengpeng Hou
  2026-03-24  4:17 ` bluez.test.bot
  2026-03-24 19:58 ` [PATCH] " Luiz Augusto von Dentz
@ 2026-03-25  0:42 ` Pengpeng Hou
  2026-03-25  2:05   ` [v2] " bluez.test.bot
  2026-03-26 18:30   ` [PATCH v2] " patchwork-bot+bluetooth
  2 siblings, 2 replies; 6+ messages in thread
From: Pengpeng Hou @ 2026-03-25  0:42 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, pengpeng

btusb_work() maps the number of active SCO links to USB alternate
settings through a three-entry lookup table when CVSD traffic uses
transparent voice settings. The lookup currently indexes alts[] with
data->sco_num - 1 without first constraining sco_num to the number of
available table entries.

While the table only defines alternate settings for up to three SCO
links, data->sco_num comes from hci_conn_num() and is used directly.
Cap the lookup to the last table entry before indexing it so the
driver keeps selecting the highest supported alternate setting without
reading past alts[].

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
v2:
- rewrite the clamped SCO table index as an explicit 0-based clamp
  to avoid wraparound concerns raised in review

 drivers/bluetooth/btusb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a1c5eb993e47..5c535f3ab722 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2376,8 +2376,11 @@ static void btusb_work(struct work_struct *work)
 		if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) {
 			if (hdev->voice_setting & 0x0020) {
 				static const int alts[3] = { 2, 4, 5 };
+				unsigned int sco_idx;
 
-				new_alts = alts[data->sco_num - 1];
+				sco_idx = min_t(unsigned int, data->sco_num - 1,
+						ARRAY_SIZE(alts) - 1);
+				new_alts = alts[sco_idx];
 			} else {
 				new_alts = data->sco_num;
 			}
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [v2] Bluetooth: btusb: clamp SCO altsetting table indices
  2026-03-25  0:42 ` [PATCH v2] " Pengpeng Hou
@ 2026-03-25  2:05   ` bluez.test.bot
  2026-03-26 18:30   ` [PATCH v2] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-03-25  2:05 UTC (permalink / raw)
  To: linux-bluetooth, pengpeng

[-- Attachment #1: Type: text/plain, Size: 2833 bytes --]

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=1071975

---Test result---

Test Summary:
CheckPatch                    PENDING   0.56 seconds
GitLint                       PENDING   0.35 seconds
SubjectPrefix                 PASS      0.07 seconds
BuildKernel                   PASS      25.33 seconds
CheckAllWarning               PASS      27.89 seconds
CheckSparse                   PASS      26.74 seconds
BuildKernel32                 PASS      24.90 seconds
TestRunnerSetup               PASS      530.75 seconds
TestRunner_l2cap-tester       PASS      27.98 seconds
TestRunner_iso-tester         FAIL      34.82 seconds
TestRunner_bnep-tester        PASS      6.29 seconds
TestRunner_mgmt-tester        FAIL      113.95 seconds
TestRunner_rfcomm-tester      PASS      9.43 seconds
TestRunner_sco-tester         FAIL      14.44 seconds
TestRunner_ioctl-tester       PASS      10.34 seconds
TestRunner_mesh-tester        FAIL      11.43 seconds
TestRunner_smp-tester         PASS      8.66 seconds
TestRunner_userchan-tester    PASS      6.82 seconds
IncrementalBuild              PENDING   0.46 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0
Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.103 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    1.788 seconds
Mesh - Send cancel - 2                               Timed out    1.992 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Bluetooth: btusb: clamp SCO altsetting table indices
  2026-03-25  0:42 ` [PATCH v2] " Pengpeng Hou
  2026-03-25  2:05   ` [v2] " bluez.test.bot
@ 2026-03-26 18:30   ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2026-03-26 18:30 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 25 Mar 2026 08:42:45 +0800 you wrote:
> btusb_work() maps the number of active SCO links to USB alternate
> settings through a three-entry lookup table when CVSD traffic uses
> transparent voice settings. The lookup currently indexes alts[] with
> data->sco_num - 1 without first constraining sco_num to the number of
> available table entries.
> 
> While the table only defines alternate settings for up to three SCO
> links, data->sco_num comes from hci_conn_num() and is used directly.
> Cap the lookup to the last table entry before indexing it so the
> driver keeps selecting the highest supported alternate setting without
> reading past alts[].
> 
> [...]

Here is the summary with links:
  - [v2] Bluetooth: btusb: clamp SCO altsetting table indices
    https://git.kernel.org/bluetooth/bluetooth-next/c/08a198361071

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-26 18:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  2:04 [PATCH] Bluetooth: btusb: clamp SCO altsetting table indices Pengpeng Hou
2026-03-24  4:17 ` bluez.test.bot
2026-03-24 19:58 ` [PATCH] " Luiz Augusto von Dentz
2026-03-25  0:42 ` [PATCH v2] " Pengpeng Hou
2026-03-25  2:05   ` [v2] " bluez.test.bot
2026-03-26 18:30   ` [PATCH v2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox