Message ID | 20250116153635.3689890-1-luiz.dentz@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v1] Bluetooth: L2CAP: Fix slab-use-after-free Read in l2cap_send_cmd | expand |
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=926129 ---Test result--- Test Summary: CheckPatch PENDING 0.25 seconds GitLint PENDING 0.18 seconds SubjectPrefix PASS 0.11 seconds BuildKernel PASS 24.31 seconds CheckAllWarning PASS 26.63 seconds CheckSparse PASS 30.08 seconds BuildKernel32 PASS 23.88 seconds TestRunnerSetup PASS 425.24 seconds TestRunner_l2cap-tester PASS 20.46 seconds TestRunner_iso-tester PASS 36.91 seconds TestRunner_bnep-tester PASS 4.87 seconds TestRunner_mgmt-tester FAIL 120.24 seconds TestRunner_rfcomm-tester PASS 7.49 seconds TestRunner_sco-tester PASS 9.36 seconds TestRunner_ioctl-tester PASS 8.03 seconds TestRunner_mesh-tester FAIL 6.20 seconds TestRunner_smp-tester PASS 6.91 seconds TestRunner_userchan-tester PASS 5.00 seconds IncrementalBuild PENDING 0.69 seconds Details ############################## Test: CheckPatch - PENDING Desc: Run checkpatch.pl script Output: ############################## Test: GitLint - PENDING Desc: Run gitlint Output: ############################## Test: TestRunner_mgmt-tester - FAIL Desc: Run mgmt-tester with test-runner Output: Total: 490, Passed: 481 (98.2%), Failed: 5, Not Run: 4 Failed Test Cases LL Privacy - Add Device 2 (2 Devices to AL) Failed 0.170 seconds LL Privacy - Set Flags 1 (Add to RL) Failed 0.155 seconds LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.190 seconds LL Privacy - Start Discovery 1 (Disable RL) Failed 0.166 seconds LL Privacy - Set Device Flag 1 (Device Privacy) Failed 0.151 seconds ############################## Test: TestRunner_mesh-tester - FAIL Desc: Run mesh-tester with test-runner Output: Total: 10, Passed: 9 (90.0%), Failed: 1, Not Run: 0 Failed Test Cases Mesh - Send cancel - 2 Failed 0.109 seconds ############################## Test: IncrementalBuild - PENDING Desc: Incremental build with the patches in the series Output: --- Regards, Linux Bluetooth
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 27b4c4a2ba1f..00ef61609d49 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -7466,14 +7466,33 @@ static void l2cap_recv_reset(struct l2cap_conn *conn) conn->rx_len = 0; } +static struct l2cap_conn *l2cap_conn_hold_unless_zero(struct l2cap_conn *c) +{ + BT_DBG("conn %p orig refcnt %u", c, kref_read(&c->ref)); + + if (!kref_get_unless_zero(&c->ref)) + return NULL; + + return c; +} + void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) { - struct l2cap_conn *conn = hcon->l2cap_data; + struct l2cap_conn *conn; int len; + /* Lock hdev to access l2cap_data to avoid race with l2cap_conn_del */ + hci_dev_lock(hcon->hdev); + + conn = hcon->l2cap_data; + if (!conn) conn = l2cap_conn_add(hcon); + conn = l2cap_conn_hold_unless_zero(conn); + + hci_dev_unlock(hcon->hdev); + if (!conn) goto drop; @@ -7565,6 +7584,8 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) break; } + l2cap_conn_put(conn); + drop: kfree_skb(skb); }