2022-08-01 23:02:22

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH v2] 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"
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
v2: Fix lkp findings.

net/bluetooth/l2cap_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 77c0aac14539..1c39fc40591b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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;

--
2.37.1



2022-08-02 00:08:03

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v2] Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression

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

2022-08-04 00:01:15

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH v2] Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression

Hello:

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

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html