All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Bluetooth: enable context analysis
@ 2026-06-14 10:27 Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations Pauli Virtanen
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

v2:
- Add annotations to RFCOMM
- Enable analysis also for BNEP, RFCOMM, HIDP

***

Set up compiler context analysis that generate compiler warnings on
problems that Clang -Wthread-safety can detect:

https://docs.kernel.org/dev-tools/context-analysis.html

Sparse locking analysis support was removed in commit
5b63d0ae94ccfd64dcbdb693d88eb3650eb3c64c, this is its successor.

Clang 22 is required, and likely in future Clang 23 [1] (unreleased, use
snapshot eg from
https://mirrors.edge.kernel.org/pub/tools/llvm/files/prerelease/ )

This series enables the analysis and adds minimal annotations to remove
all warnings.

In future, it probably is a good idea to make more use of it and add
__must_hold, __guarded_by etc annotations.

Kernel test robot appears to be checking for these, but not sure in what
trees [2]

BlueZ testbot doesn't check these currently but it's possible to add
https://github.com/bluez/action-ci/pull/4

[1] https://lore.kernel.org/all/177996424926.1039918.344230591161201072.tip-bot2@tip-bot2/
[2] https://lore.kernel.org/all/202605060005.JYWpZXr2-lkp@intel.com/

Pauli Virtanen (5):
  Bluetooth: af_bluetooth: Add minimal context analysis annotations
  Bluetooth: hci_core: Add minimal context analysis annotations
  Bluetooth: L2CAP: Add minimal context analysis annotations
  Bluetooth: RFCOMM: Add minimal context analysis annotations
  Bluetooth: enable context analysis

 drivers/bluetooth/Makefile    | 2 ++
 net/bluetooth/Makefile        | 2 ++
 net/bluetooth/af_bluetooth.c  | 7 +++++--
 net/bluetooth/bnep/Makefile   | 2 ++
 net/bluetooth/hci_core.c      | 3 +++
 net/bluetooth/hidp/Makefile   | 2 ++
 net/bluetooth/l2cap_sock.c    | 1 +
 net/bluetooth/rfcomm/Makefile | 2 ++
 net/bluetooth/rfcomm/sock.c   | 1 +
 9 files changed, 20 insertions(+), 2 deletions(-)

-- 
2.54.0


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

* [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations
  2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
@ 2026-06-14 10:27 ` Pauli Virtanen
  2026-06-14 12:57   ` Bluetooth: enable context analysis bluez.test.bot
  2026-06-14 10:27 ` [PATCH v2 2/5] Bluetooth: hci_core: Add minimal context analysis annotations Pauli Virtanen
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Add minimal compiler context analysis annotations, required for
compilation to pass.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/af_bluetooth.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index bcbc11c9cb15..62b751203fb0 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -209,6 +209,7 @@ bool bt_sock_linked(struct bt_sock_list *l, struct sock *s)
 EXPORT_SYMBOL(bt_sock_linked);
 
 void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh)
+	__context_unsafe(/* conditional locking */)
 {
 	const struct cred *old_cred;
 	struct pid *old_pid;
@@ -826,7 +827,8 @@ EXPORT_SYMBOL(bt_sock_wait_ready);
 
 #ifdef CONFIG_PROC_FS
 static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
-	__acquires(seq->private->l->lock)
+	__acquires_shared(&((struct bt_sock_list *)
+			    pde_data(file_inode(seq->file)))->lock)
 {
 	struct bt_sock_list *l = pde_data(file_inode(seq->file));
 
@@ -842,7 +844,8 @@ static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 }
 
 static void bt_seq_stop(struct seq_file *seq, void *v)
-	__releases(seq->private->l->lock)
+	__releases_shared(&((struct bt_sock_list *)
+			    pde_data(file_inode(seq->file)))->lock)
 {
 	struct bt_sock_list *l = pde_data(file_inode(seq->file));
 
-- 
2.54.0


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

* [PATCH v2 2/5] Bluetooth: hci_core: Add minimal context analysis annotations
  2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations Pauli Virtanen
@ 2026-06-14 10:27 ` Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 3/5] Bluetooth: L2CAP: " Pauli Virtanen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Add minimal compiler context analysis annotations, required for
compilation to pass.

compiler-context-analysis.h doesn't have tools to deal with the
conditional SRCU locking on return value used here, so just disable the
analysis in places instead of refactoring, in order to not make code
changes here.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/hci_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 5ba9fe8261ec..d1e78ae7728e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -62,6 +62,7 @@ static DEFINE_IDA(hci_index_ida);
 /* Get HCI device by index.
  * Device is held on return. */
 static struct hci_dev *__hci_dev_get(int index, int *srcu_index)
+	__context_unsafe(/* conditional locking */)
 {
 	struct hci_dev *hdev = NULL, *d;
 
@@ -89,11 +90,13 @@ struct hci_dev *hci_dev_get(int index)
 }
 
 static struct hci_dev *hci_dev_get_srcu(int index, int *srcu_index)
+	__context_unsafe(/* conditional locking vs return */)
 {
 	return __hci_dev_get(index, srcu_index);
 }
 
 static void hci_dev_put_srcu(struct hci_dev *hdev, int srcu_index)
+	__context_unsafe(/* conditional locking vs return */)
 {
 	srcu_read_unlock(&hdev->srcu, srcu_index);
 	hci_dev_put(hdev);
-- 
2.54.0


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

* [PATCH v2 3/5] Bluetooth: L2CAP: Add minimal context analysis annotations
  2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 2/5] Bluetooth: hci_core: Add minimal context analysis annotations Pauli Virtanen
@ 2026-06-14 10:27 ` Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 4/5] Bluetooth: RFCOMM: " Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 5/5] Bluetooth: enable context analysis Pauli Virtanen
  4 siblings, 0 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Add minimal compiler context analysis annotations, required for
compilation to pass.

Don't check complex conn->lock usage in l2cap_sock_shutdown().  The
analysis cannot know that chan->conn pointer is never replaced by a
different l2cap_conn.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/l2cap_sock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 4853f1b33449..8558a7071ff5 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1351,6 +1351,7 @@ static int __l2cap_wait_ack(struct sock *sk, struct l2cap_chan *chan)
 }
 
 static int l2cap_sock_shutdown(struct socket *sock, int how)
+	__context_unsafe(/* complex chan->conn locking */)
 {
 	struct sock *sk = sock->sk;
 	struct l2cap_chan *chan;
-- 
2.54.0


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

* [PATCH v2 4/5] Bluetooth: RFCOMM: Add minimal context analysis annotations
  2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
                   ` (2 preceding siblings ...)
  2026-06-14 10:27 ` [PATCH v2 3/5] Bluetooth: L2CAP: " Pauli Virtanen
@ 2026-06-14 10:27 ` Pauli Virtanen
  2026-06-14 10:27 ` [PATCH v2 5/5] Bluetooth: enable context analysis Pauli Virtanen
  4 siblings, 0 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Add minimal compiler context analysis annotations, required for
compilation to pass.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/rfcomm/sock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index feb302a491fa..958081adb9b5 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -60,6 +60,7 @@ static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb)
 }
 
 static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
+	__must_hold(&d->lock)
 {
 	struct sock *sk = d->owner, *parent;
 
-- 
2.54.0


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

* [PATCH v2 5/5] Bluetooth: enable context analysis
  2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
                   ` (3 preceding siblings ...)
  2026-06-14 10:27 ` [PATCH v2 4/5] Bluetooth: RFCOMM: " Pauli Virtanen
@ 2026-06-14 10:27 ` Pauli Virtanen
  4 siblings, 0 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-06-14 10:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Enable compiler context analysis for Bluetooth subsystem and drivers.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 drivers/bluetooth/Makefile    | 2 ++
 net/bluetooth/Makefile        | 2 ++
 net/bluetooth/bnep/Makefile   | 2 ++
 net/bluetooth/hidp/Makefile   | 2 ++
 net/bluetooth/rfcomm/Makefile | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index bafc26250b63..e6b1c1180d1d 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -50,3 +50,5 @@ hci_uart-$(CONFIG_BT_HCIUART_AG6XX)	+= hci_ag6xx.o
 hci_uart-$(CONFIG_BT_HCIUART_MRVL)	+= hci_mrvl.o
 hci_uart-$(CONFIG_BT_HCIUART_AML)	+= hci_aml.o
 hci_uart-objs				:= $(hci_uart-y)
+
+CONTEXT_ANALYSIS := y
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index 41049b280887..ff466ea97436 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -25,3 +25,5 @@ bluetooth-$(CONFIG_BT_MSFTEXT) += msft.o
 bluetooth-$(CONFIG_BT_AOSPEXT) += aosp.o
 bluetooth-$(CONFIG_BT_DEBUGFS) += hci_debugfs.o
 bluetooth-$(CONFIG_BT_SELFTEST) += selftest.o
+
+CONTEXT_ANALYSIS := y
diff --git a/net/bluetooth/bnep/Makefile b/net/bluetooth/bnep/Makefile
index 8af9d56bb012..f42015cc3245 100644
--- a/net/bluetooth/bnep/Makefile
+++ b/net/bluetooth/bnep/Makefile
@@ -6,3 +6,5 @@
 obj-$(CONFIG_BT_BNEP) += bnep.o
 
 bnep-objs := core.o sock.o netdev.o
+
+CONTEXT_ANALYSIS := y
diff --git a/net/bluetooth/hidp/Makefile b/net/bluetooth/hidp/Makefile
index f41b0aa02b23..53e139e41bdc 100644
--- a/net/bluetooth/hidp/Makefile
+++ b/net/bluetooth/hidp/Makefile
@@ -6,3 +6,5 @@
 obj-$(CONFIG_BT_HIDP) += hidp.o
 
 hidp-objs := core.o sock.o
+
+CONTEXT_ANALYSIS := y
diff --git a/net/bluetooth/rfcomm/Makefile b/net/bluetooth/rfcomm/Makefile
index 593e5c48c131..15f909f40f25 100644
--- a/net/bluetooth/rfcomm/Makefile
+++ b/net/bluetooth/rfcomm/Makefile
@@ -7,3 +7,5 @@ obj-$(CONFIG_BT_RFCOMM) += rfcomm.o
 
 rfcomm-y			:= core.o sock.o
 rfcomm-$(CONFIG_BT_RFCOMM_TTY)	+= tty.o
+
+CONTEXT_ANALYSIS := y
-- 
2.54.0


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

* RE: Bluetooth: enable context analysis
  2026-06-14 10:27 ` [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations Pauli Virtanen
@ 2026-06-14 12:57   ` bluez.test.bot
  0 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2026-06-14 12:57 UTC (permalink / raw)
  To: linux-bluetooth, pav

[-- Attachment #1: Type: text/plain, Size: 2794 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=1111252

---Test result---

Test Summary:
CheckPatch                    PASS      3.44 seconds
VerifyFixes                   PASS      0.07 seconds
VerifySignedoff               PASS      0.07 seconds
GitLint                       PASS      0.98 seconds
SubjectPrefix                 PASS      0.54 seconds
BuildKernel                   PASS      26.52 seconds
CheckAllWarning               PASS      29.29 seconds
CheckSparse                   PASS      28.58 seconds
BuildKernel32                 PASS      26.00 seconds
TestRunnerSetup               PASS      575.93 seconds
TestRunner_l2cap-tester       PASS      58.42 seconds
TestRunner_iso-tester         PASS      87.26 seconds
TestRunner_bnep-tester        PASS      19.12 seconds
TestRunner_mgmt-tester        FAIL      208.56 seconds
TestRunner_rfcomm-tester      PASS      25.04 seconds
TestRunner_sco-tester         PASS      32.00 seconds
TestRunner_ioctl-tester       PASS      25.73 seconds
TestRunner_mesh-tester        FAIL      25.83 seconds
TestRunner_smp-tester         PASS      24.88 seconds
TestRunner_userchan-tester    PASS      19.72 seconds
TestRunner_6lowpan-tester     FAIL      45.81 seconds
IncrementalBuild              PASS      33.20 seconds

Details
##############################
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.236 seconds
##############################
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    2.574 seconds
Mesh - Send cancel - 2                               Timed out    1.991 seconds
##############################
Test: TestRunner_6lowpan-tester - FAIL
Desc: Run 6lowpan-tester with test-runner
Output:
Total: 8, Passed: 3 (37.5%), Failed: 5, Not Run: 0

Failed Test Cases
Client Connect - Disconnect                          Timed out    5.323 seconds
Client Recv Dgram - Success                          Timed out    4.988 seconds
Client Recv Raw - Success                            Timed out    5.015 seconds
Client Recv IPHC Dgram - Success                     Timed out    4.978 seconds
Client Recv IPHC Raw - Success                       Timed out    5.004 seconds


https://github.com/bluez/bluetooth-next/pull/314

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-06-14 12:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-14 10:27 [PATCH v2 0/5] Bluetooth: enable context analysis Pauli Virtanen
2026-06-14 10:27 ` [PATCH v2 1/5] Bluetooth: af_bluetooth: Add minimal context analysis annotations Pauli Virtanen
2026-06-14 12:57   ` Bluetooth: enable context analysis bluez.test.bot
2026-06-14 10:27 ` [PATCH v2 2/5] Bluetooth: hci_core: Add minimal context analysis annotations Pauli Virtanen
2026-06-14 10:27 ` [PATCH v2 3/5] Bluetooth: L2CAP: " Pauli Virtanen
2026-06-14 10:27 ` [PATCH v2 4/5] Bluetooth: RFCOMM: " Pauli Virtanen
2026-06-14 10:27 ` [PATCH v2 5/5] Bluetooth: enable context analysis Pauli Virtanen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.