[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230524170415.kernel.v1.1.I575ec21daa35ebba038fe38e164df60b6121c633@changeid>
Date: Wed, 24 May 2023 17:04:15 -0700
From: Zhengping Jiang <jiangzp@...gle.com>
To: linux-bluetooth@...r.kernel.org, marcel@...tmann.org, luiz.dentz@...il.com
Cc: chromeos-bluetooth-upstreaming@...omium.org,
Zhengping Jiang <jiangzp@...gle.com>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Johan Hedberg <johan.hedberg@...il.com>, Paolo Abeni <pabeni@...hat.com>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [kernel PATCH v1] Bluetooth: L2CAP: Fix use-after-free
Fix potential use-after-free in l2cap_le_command_rej.
Signed-off-by: Zhengping Jiang <jiangzp@...gle.com>
---
Changes in v1:
- Use l2cap_chan_hold_unless_zero to prevent adding refcnt when it is
already 0.
net/bluetooth/l2cap_core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 376b523c7b26..19b0b1f7ffed 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6361,9 +6361,14 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn,
if (!chan)
goto done;
+ chan = l2cap_chan_hold_unless_zero(chan);
+ if (!chan)
+ goto done;
+
l2cap_chan_lock(chan);
l2cap_chan_del(chan, ECONNREFUSED);
l2cap_chan_unlock(chan);
+ l2cap_chan_put(chan);
done:
mutex_unlock(&conn->chan_lock);
--
2.40.1.698.g37aff9b760-goog
Powered by blists - more mailing lists