Skip to content

[PW_SID:1154686] [v1] Bluetooth: btusb: Fix UAF of btusb_data by rx_work - #675

Closed
BluezTestBot wants to merge 7 commits into
workflowfrom
1154686
Closed

[PW_SID:1154686] [v1] Bluetooth: btusb: Fix UAF of btusb_data by rx_work#675
BluezTestBot wants to merge 7 commits into
workflowfrom
1154686

Conversation

@BluezTestBot

Copy link
Copy Markdown

From: Luiz Augusto von Dentz luiz.von.dentz@intel.com

btusb_close() and btusb_flush() cancel data->rx_work with the
asynchronous cancel_delayed_work(), so if btusb_rx_work() is already
running on another CPU it keeps running after the cancel returns.

btusb_disconnect() calls hci_unregister_dev(), which invokes
btusb_close(), and then frees the btusb_data. A still running
btusb_rx_work() then dereferences the freed data:

while ((skb = skb_dequeue(&data->acl_q)))
	data->recv_acl(data->hdev, skb);

Use cancel_delayed_work_sync() instead. In btusb_close() the cancel also
has to happen after btusb_stop_traffic(), otherwise an URB completion
racing with the cancel can requeue the work right after it has been
waited for.

Fixes: 800fe5e ("Bluetooth: btusb: Add support for queuing during polling interval")
Signed-off-by: Luiz Augusto von Dentz luiz.von.dentz@intel.com

drivers/bluetooth/btusb.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

tedd-an and others added 7 commits August 28, 2026 00:40
This patch adds workflow files for ci:

[sync.yml]
 - The workflow file for scheduled work
 - Sync the repo with upstream repo and rebase the workflow branch
 - Review the patches in the patchwork and creates the PR if needed

[ci.yml]
 - The workflow file for CI tasks
 - Run CI tests when PR is created

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
This replaces the bzcafe action with bluez/action-ci so we can maintain
everything in the github bluez organization

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This attempts to sync every 5 minutes instead of 30.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
bluez/action-ci uses master as default branch for workflow which is
incorrect for kernel

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The CI action now creates individual GitHub Check Runs per test, which
requires 'checks: write' permission on the GITHUB_TOKEN. Also make the
pull_request trigger types explicit to include 'reopened', allowing CI
to be retriggered by closing and reopening a PR.
btusb_close() and btusb_flush() cancel data->rx_work with the
asynchronous cancel_delayed_work(), so if btusb_rx_work() is already
running on another CPU it keeps running after the cancel returns.

btusb_disconnect() calls hci_unregister_dev(), which invokes
btusb_close(), and then frees the btusb_data. A still running
btusb_rx_work() then dereferences the freed data:

	while ((skb = skb_dequeue(&data->acl_q)))
		data->recv_acl(data->hdev, skb);

Use cancel_delayed_work_sync() instead. In btusb_close() the cancel also
has to happen after btusb_stop_traffic(), otherwise an URB completion
racing with the cancel can requeue the work right after it has been
waited for.

Fixes: 800fe5e ("Bluetooth: btusb: Add support for queuing during polling interval")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for Bulk Serialization Mode introduced in 6.2:

https://www.bluetooth.com/bluetooth-core-6-2-feature-overview/#5-bluetooth-hci-usb-le-isochronous-support
https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host-controller-interface/usb-transport-layer.html#UUID-c1a65395-29e9-87d3-2981-8bed625d0459

It works by detecting if alternate setting 1 is supported for the
interface and then switches to use it as it serializes all the frames
in a single Bulk endpoint using H4 headers and it considerable more
robust then legacy one while allowing the transport of ISO packets:

 'In addition to enabling Bluetooth® LE Audio, the new mode resolves a
 persistent race condition in the legacy USB transport layer. In Legacy
 Mode, different endpoint types are serviced in a specific order within
 a USB frame, which can result in out-of-order delivery of data and
 events. For example, a Host might receive a data packet before the
 event signaling its arrival. This behavior can disrupt critical
 processes such as connection setup, disconnection, and data encryption,
 adversely affecting the user experience.'

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
@github-actions

Copy link
Copy Markdown

CheckPatch
Desc: Run checkpatch.pl script
Duration: 1.34 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

VerifyFixes
Desc: Verify Fixes tag format and validity
Duration: 0.11 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

VerifySignedoff
Desc: Verify Signed-off-by chain
Duration: 0.46 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

GitLint
Desc: Run gitlint
Duration: 0.55 seconds
Result: FAIL
Output:

[v1] Bluetooth: btusb: Fix UAF of btusb_data by rx_work

13: B3 Line contains hard tab characters (\t): "	while ((skb = skb_dequeue(&data->acl_q)))"
14: B3 Line contains hard tab characters (\t): "		data->recv_acl(data->hdev, skb);"

@github-actions

Copy link
Copy Markdown

SubjectPrefix
Desc: Check subject contains "Bluetooth" prefix
Duration: 0.20 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

BuildKernel
Desc: Build Kernel for Bluetooth
Duration: 23.36 seconds
Result: FAIL
Output:


drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions

Copy link
Copy Markdown

CheckAllWarning
Desc: Run linux kernel with all warning enabled
Duration: 25.43 seconds
Result: FAIL
Output:


drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions

Copy link
Copy Markdown

CheckSparse
Desc: Run sparse tool with linux kernel
Duration: 24.40 seconds
Result: FAIL
Output:


/github/workspace/src/src/Makefile:1283: C=1 specified, but sparse is not available or not up to date
/github/workspace/src/src/Makefile:1283: C=1 specified, but sparse is not available or not up to date
drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions

Copy link
Copy Markdown

BuildKernel32
Desc: Build 32bit Kernel for Bluetooth
Duration: 22.01 seconds
Result: FAIL
Output:


drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions

Copy link
Copy Markdown

CheckKernelLLVM
Desc: Build kernel with LLVM + context analysis
Duration: 0.00 seconds
Result: SKIP
Output:

Clang not found

@github-actions

Copy link
Copy Markdown

TestRunnerSetup
Desc: Setup kernel and bluez for test-runner
Duration: 445.05 seconds
Result: FAIL
Output:

Kernel: 
drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions

Copy link
Copy Markdown

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 25.56 seconds
Result: FAIL
Output:


drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[v3,2/2] Bluetooth: btusb: Add support for Bulk Serialization Mode

drivers/bluetooth/btusb.c: In function ‘btusb_recv_h4’:
drivers/bluetooth/btusb.c:1385:17: error: implicit declaration of function ‘h4_recv_skb’; did you mean ‘h4_recv_buf’? [-Werror=implicit-function-declaration]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |                 ^~~~~~~~~~~
      |                 h4_recv_buf
drivers/bluetooth/btusb.c:1385:15: warning: assignment to ‘struct sk_buff *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1385 |  data->rx_skb = h4_recv_skb(data->hdev, NULL, NULL, data->rx_skb, buffer,
      |               ^
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/bluetooth/btusb.o] Error 1
make[3]: *** [scripts/Makefile.build:549: drivers/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: drivers] Error 2
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

@github-actions
github-actions Bot force-pushed the workflow branch 3 times, most recently from b3d5ba7 to 5de3a3b Compare September 2, 2026 23:33
@BluezTestBot
BluezTestBot deleted the 1154686 branch September 2, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants