diff mbox series

[1/2] Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails

Message ID 20210519204151.1087613-1-luiz.dentz@gmail.com
State New
Headers show
Series [1/2] Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails | expand

Commit Message

Luiz Augusto von Dentz May 19, 2021, 8:41 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The use of l2cap_chan_del is not safe under a loop using
list_for_each_entry.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/l2cap_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

bluez.test.bot@gmail.com May 19, 2021, 9:09 p.m. UTC | #1
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=485329

---Test result---

Test Summary:
CheckPatch                    PASS      1.40 seconds
GitLint                       PASS      0.33 seconds
BuildKernel                   PASS      569.82 seconds
TestRunner: Setup             PASS      380.04 seconds
TestRunner: l2cap-tester      PASS      2.79 seconds
TestRunner: bnep-tester       PASS      1.98 seconds
TestRunner: mgmt-tester       PASS      27.09 seconds
TestRunner: rfcomm-tester     PASS      2.17 seconds
TestRunner: sco-tester        PASS      2.05 seconds
TestRunner: smp-tester        PASS      2.22 seconds
TestRunner: userchan-tester   PASS      2.00 seconds

Details
##############################
Test: CheckPatch - PASS - 1.40 seconds
Run checkpatch.pl script with rule in .checkpatch.conf


##############################
Test: GitLint - PASS - 0.33 seconds
Run gitlint with rule in .gitlint


##############################
Test: BuildKernel - PASS - 569.82 seconds
Build Kernel with minimal configuration supports Bluetooth


##############################
Test: TestRunner: Setup - PASS - 380.04 seconds
Setup environment for running Test Runner


##############################
Test: TestRunner: l2cap-tester - PASS - 2.79 seconds
Run test-runner with l2cap-tester
Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: bnep-tester - PASS - 1.98 seconds
Run test-runner with bnep-tester
Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: mgmt-tester - PASS - 27.09 seconds
Run test-runner with mgmt-tester
Total: 416, Passed: 403 (96.9%), Failed: 0, Not Run: 13

##############################
Test: TestRunner: rfcomm-tester - PASS - 2.17 seconds
Run test-runner with rfcomm-tester
Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: sco-tester - PASS - 2.05 seconds
Run test-runner with sco-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: smp-tester - PASS - 2.22 seconds
Run test-runner with smp-tester
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: TestRunner: userchan-tester - PASS - 2.00 seconds
Run test-runner with userchan-tester
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0



---
Regards,
Linux Bluetooth
Marcel Holtmann May 20, 2021, 3:19 p.m. UTC | #2
Hi Luiz,

> The use of l2cap_chan_del is not safe under a loop using

> list_for_each_entry.

> 

> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

> ---

> net/bluetooth/l2cap_core.c | 4 ++--

> 1 file changed, 2 insertions(+), 2 deletions(-)


patch has been applied to bluetooth-next tree.

Regards

Marcel
Marcel Holtmann May 20, 2021, 3:19 p.m. UTC | #3
Hi Luiz,

> The use of l2cap_chan_del is not safe under a loop using

> list_for_each_entry.

> 

> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

> ---

> net/bluetooth/l2cap_core.c | 4 ++--

> 1 file changed, 2 insertions(+), 2 deletions(-)


patch has been applied to bluetooth-next tree.

Regards

Marcel
diff mbox series

Patch

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 7d975cf98c20..f3b70fa348ab 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6248,7 +6248,7 @@  static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
 					 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
 					 u8 *data)
 {
-	struct l2cap_chan *chan;
+	struct l2cap_chan *chan, *tmp;
 	struct l2cap_ecred_conn_rsp *rsp = (void *) data;
 	u16 result;
 
@@ -6262,7 +6262,7 @@  static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
 	if (!result)
 		return 0;
 
-	list_for_each_entry(chan, &conn->chan_l, list) {
+	list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
 		if (chan->ident != cmd->ident)
 			continue;