Skip to contentSkip to conversation

Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Aug 1, 2022 – Aug 4, 2022

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression

From: Luiz Augusto von Dentz <[email protected]>

The patch d0be8347c623: "Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put" from Jul 21, 2022, leads to the following Smatch static checker warning:

net/bluetooth/l2cap_core.c:1977 l2cap_global_chan_by_psm()
error: we previously assumed 'c' could be null (see line 1996)

Fixes d0be8347c623: "Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put"

---
v2: Fix lkp findings.

 net/bluetooth/l2cap_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/l2cap_core.c +2 -2
index 77c0aac14539..1c39fc40591b 100644
@@ -1970,11 +1970,11 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
 						   bdaddr_t *dst,
 						   u8 link_type)
 {
-	struct l2cap_chan *c, *c1 = NULL;
+	struct l2cap_chan *c, *tmp, *c1 = NULL;
 
 	read_lock(&chan_list_lock);
 
-	list_for_each_entry(c, &chan_list, global_l) {
+	list_for_each_entry_safe(c, tmp, &chan_list, global_l) {
 		if (state && c->state != state)
 			continue;
 
Signature · 1 line
2.37.1
#1 lore raw

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

---Test result---

Test Summary:

CheckPatch                    PASS      2.76 seconds
GitLint                       PASS      1.00 seconds
SubjectPrefix                 PASS      0.88 seconds
BuildKernel                   PASS      35.02 seconds
BuildKernel32                 PASS      29.23 seconds
Incremental Build with patchesPASS      40.79 seconds
TestRunner: Setup             PASS      484.64 seconds
TestRunner: l2cap-tester      PASS      17.78 seconds
TestRunner: bnep-tester       PASS      6.74 seconds
TestRunner: mgmt-tester       PASS      101.36 seconds
TestRunner: rfcomm-tester     PASS      10.23 seconds
TestRunner: sco-tester        PASS      9.72 seconds
TestRunner: smp-tester        PASS      10.17 seconds
TestRunner: userchan-tester   PASS      6.57 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 10 lines · On Mon, 1 Aug 2022 15:57:02 -0700 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

The patch d0be8347c623: "Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put" from Jul 21, 2022, leads to the following Smatch static checker warning:

net/bluetooth/l2cap_core.c:1977 l2cap_global_chan_by_psm()
error: we previously assumed 'c' could be null (see line 1996)

[...]

Here is the summary with links:
- [v2] Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression
https://git.kernel.org/bluetooth/bluetooth-next/c/600f1aff2dcb

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html