Skip to content

[PW_SID:1058928] Bluetooth: MGMT: Fix list corruption and UAF in command complete handlers#3335

Open
BluezTestBot wants to merge 2 commits intoworkflowfrom
1058928
Open

[PW_SID:1058928] Bluetooth: MGMT: Fix list corruption and UAF in command complete handlers#3335
BluezTestBot wants to merge 2 commits intoworkflowfrom
1058928

Conversation

@BluezTestBot
Copy link
Owner

Commit 302a1f6 ("Bluetooth: MGMT: Fix possible UAFs") introduced
mgmt_pending_valid(), which not only validates the pending command but
also unlinks it from the pending list if it is valid. This change in
semantics requires updates to several completion handlers to avoid list
corruption and memory safety issues.

This patch addresses two left-over issues from the aforementioned rework:

  1. In mgmt_add_adv_patterns_monitor_complete(), mgmt_pending_remove()
    is replaced with mgmt_pending_free() in the success path. Since
    mgmt_pending_valid() already unlinks the command at the beginning of
    the function, calling mgmt_pending_remove() leads to a double list_del()
    and subsequent list corruption/kernel panic.

  2. In set_mesh_complete(), the use of mgmt_pending_foreach() in the error
    path is removed. Since the current command is already unlinked by
    mgmt_pending_valid(), this foreach loop would incorrectly target other
    pending mesh commands, potentially freeing them while they are still being
    processed concurrently (leading to UAFs). The redundant mgmt_cmd_status()
    is also simplified to use cmd->opcode directly.

Fixes: 302a1f6 ("Bluetooth: MGMT: Fix possible UAFs")
Signed-off-by: Wang Tao wangtao554@huawei.com

net/bluetooth/mgmt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

tedd-an and others added 2 commits February 25, 2026 20:41
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>
…lers

Commit 302a1f6 ("Bluetooth: MGMT: Fix possible UAFs") introduced
mgmt_pending_valid(), which not only validates the pending command but
also unlinks it from the pending list if it is valid. This change in
semantics requires updates to several completion handlers to avoid list
corruption and memory safety issues.

This patch addresses two left-over issues from the aforementioned rework:

1. In mgmt_add_adv_patterns_monitor_complete(), mgmt_pending_remove()
is replaced with mgmt_pending_free() in the success path. Since
mgmt_pending_valid() already unlinks the command at the beginning of
the function, calling mgmt_pending_remove() leads to a double list_del()
and subsequent list corruption/kernel panic.

2. In set_mesh_complete(), the use of mgmt_pending_foreach() in the error
path is removed. Since the current command is already unlinked by
mgmt_pending_valid(), this foreach loop would incorrectly target other
pending mesh commands, potentially freeing them while they are still being
processed concurrently (leading to UAFs). The redundant mgmt_cmd_status()
is also simplified to use cmd->opcode directly.

Fixes: 302a1f6 ("Bluetooth: MGMT: Fix possible UAFs")
Signed-off-by: Wang Tao <wangtao554@huawei.com>
@github-actions
Copy link

CheckPatch
Desc: Run checkpatch.pl script
Duration: 0.34 seconds
Result: PENDING

@github-actions
Copy link

GitLint
Desc: Run gitlint
Duration: 0.22 seconds
Result: PENDING

@github-actions
Copy link

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

@github-actions
Copy link

BuildKernel
Desc: Build Kernel for Bluetooth
Duration: 26.66 seconds
Result: PASS

@github-actions
Copy link

CheckAllWarning
Desc: Run linux kernel with all warning enabled
Duration: 29.41 seconds
Result: PASS

@github-actions
Copy link

CheckSparse
Desc: Run sparse tool with linux kernel
Duration: 33.30 seconds
Result: PASS

@github-actions
Copy link

BuildKernel32
Desc: Build 32bit Kernel for Bluetooth
Duration: 26.49 seconds
Result: PASS

@github-actions
Copy link

TestRunnerSetup
Desc: Setup kernel and bluez for test-runner
Duration: 576.25 seconds
Result: PASS

@github-actions
Copy link

TestRunner_l2cap-tester
Desc: Run l2cap-tester with test-runner
Duration: 29.23 seconds
Result: PASS

@github-actions
Copy link

TestRunner_iso-tester
Desc: Run iso-tester with test-runner
Duration: 60.16 seconds
Result: FAIL
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

@github-actions
Copy link

TestRunner_bnep-tester
Desc: Run bnep-tester with test-runner
Duration: 6.56 seconds
Result: PASS

@github-actions
Copy link

TestRunner_mgmt-tester
Desc: Run mgmt-tester with test-runner
Duration: 126.65 seconds
Result: FAIL
Output:

Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.111 seconds

@github-actions
Copy link

TestRunner_rfcomm-tester
Desc: Run rfcomm-tester with test-runner
Duration: 9.69 seconds
Result: PASS

@github-actions
Copy link

TestRunner_sco-tester
Desc: Run sco-tester with test-runner
Duration: 14.92 seconds
Result: FAIL
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

@github-actions
Copy link

TestRunner_ioctl-tester
Desc: Run ioctl-tester with test-runner
Duration: 10.41 seconds
Result: PASS

@github-actions
Copy link

TestRunner_mesh-tester
Desc: Run mesh-tester with test-runner
Duration: 12.46 seconds
Result: FAIL
Output:

Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    2.470 seconds
Mesh - Send cancel - 2                               Timed out    1.996 seconds

@github-actions
Copy link

TestRunner_smp-tester
Desc: Run smp-tester with test-runner
Duration: 8.88 seconds
Result: PASS

@github-actions
Copy link

TestRunner_userchan-tester
Desc: Run userchan-tester with test-runner
Duration: 6.84 seconds
Result: PASS

@github-actions
Copy link

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 0.90 seconds
Result: PENDING

@github-actions github-actions bot force-pushed the workflow branch 3 times, most recently from f27164a to e9dd054 Compare March 2, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants