Skip to content

[PW_SID:1126083] [1/2] Bluetooth: L2CAP: avoid maybe-return-locked and add locking annotations#426

Open
BluezTestBot wants to merge 2 commits into
workflowfrom
1126083
Open

[PW_SID:1126083] [1/2] Bluetooth: L2CAP: avoid maybe-return-locked and add locking annotations#426
BluezTestBot wants to merge 2 commits into
workflowfrom
1126083

Conversation

@BluezTestBot

Copy link
Copy Markdown

Replace the maybe-return-locked behavior of
l2cap_get_chan_by_scid/dcid() by doing locking in the caller after NULL
check. This allows the static context analysis to handle this. No
functional change intended.

Add context analysis annotations related to l2cap_chan_lock/unlock().

Signed-off-by: Pauli Virtanen pav@iki.fi

Notes:
Possibly the l2cap_ops::alloc_skb callback should have generally
__must_hold(&chan->lock) and not just in l2cap_sock.c

This would imply l2cap_chan_send() should hold the lock, but trying to
add the annotations reveals l2cap_chan_send is called without chan->lock
from some places:

net/bluetooth/smp.c:589:2: warning: calling function 'l2cap_chan_send' requires holding mutex 'conn->smp->lock' exclusively [-Wthread-safety-analysis]
  589 |         l2cap_chan_send(chan, &msg, 1 + len, NULL);
      |         ^
1 warning generated.
net/bluetooth/6lowpan.c:455:8: warning: calling function 'l2cap_chan_send' requires holding mutex 'chan->lock' exclusively [-Wthread-safety-analysis]
  455 |         err = l2cap_chan_send(chan, &msg, skb->len, NULL);
      |               ^

Don't know now if the context in these places allows l2cap_chan_lock()

include/net/bluetooth/l2cap.h | 2 ++
net/bluetooth/l2cap_core.c | 25 +++++++++++++++++--------
net/bluetooth/l2cap_sock.c | 1 +
3 files changed, 20 insertions(+), 8 deletions(-)

pv added 2 commits July 12, 2026 14:08
Replace the maybe-return-locked behavior of
l2cap_get_chan_by_scid/dcid() by doing locking in the caller after NULL
check. This allows the static context analysis to handle this.  No
functional change intended.

Add context analysis annotations related to l2cap_chan_lock/unlock().

Signed-off-by: Pauli Virtanen <pav@iki.fi>
Remove context analysis suppression for include/net/bluetooth/*, now
that previous commits have resolved the warnings.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

[1/2] Bluetooth: L2CAP: avoid maybe-return-locked and add locking annotations

16: B2 Line has trailing whitespace: "    "
20: B2 Line has trailing whitespace: "    "
21: B1 Line exceeds max length (154>80): "    net/bluetooth/smp.c:589:2: warning: calling function 'l2cap_chan_send' requires holding mutex 'conn->smp->lock' exclusively [-Wthread-safety-analysis]"
25: B1 Line exceeds max length (153>80): "    net/bluetooth/6lowpan.c:455:8: warning: calling function 'l2cap_chan_send' requires holding mutex 'chan->lock' exclusively [-Wthread-safety-analysis]"
28: B2 Line has trailing whitespace: "    "

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@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: 464.52 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

TestRunner_l2cap-tester
Desc: Run l2cap-tester with test-runner
Duration: 59.28 seconds
Result: FAIL
Output:

Total: 96, Passed: 95 (99.0%), Failed: 1, Not Run: 0

Failed Test Cases
L2CAP BR/EDR Server - Set PHY 2M                     Failed       0.252 seconds

@github-actions

Copy link
Copy Markdown

TestRunner_iso-tester
Desc: Run iso-tester with test-runner
Duration: 85.82 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

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

Failed Test Cases
Read Exp Feature - Success                           Failed       0.244 seconds

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

TestRunner_sco-tester
Desc: Run sco-tester with test-runner
Duration: 32.35 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

TestRunner_mesh-tester
Desc: Run mesh-tester with test-runner
Duration: 26.05 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.622 seconds
Mesh - Send cancel - 2                               Timed out    1.989 seconds

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

TestRunner_6lowpan-tester
Desc: Run 6lowpan-tester with test-runner
Duration: 22.91 seconds
Result: PASS

@github-actions

Copy link
Copy Markdown

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 25.30 seconds
Result: PASS

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.

2 participants