From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Zhengping Jiang <jiangzp@google.com>,
Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
marcel@holtmann.org, gustavo@padovan.org,
johan.hedberg@gmail.com, davem@davemloft.net,
linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 08/12] Bluetooth: L2CAP: Fix use-after-free
Date: Sun, 23 Jul 2023 21:34:21 -0400 [thread overview]
Message-ID: <20230724013426.2333833-8-sashal@kernel.org> (raw)
In-Reply-To: <20230724013426.2333833-1-sashal@kernel.org>
From: Zhengping Jiang <jiangzp@google.com>
[ Upstream commit f752a0b334bb95fe9b42ecb511e0864e2768046f ]
Fix potential use-after-free in l2cap_le_command_rej.
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 e56863587ea2e..61bf489265505 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5723,9 +5723,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.39.2
next prev parent reply other threads:[~2023-07-24 1:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 1:34 [PATCH AUTOSEL 5.4 01/12] media: v4l2-mem2mem: add lock to protect parameter num_rdy Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 02/12] media: platform: mediatek: vpu: fix NULL ptr dereference Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 03/12] xhci: Don't require a valid get_quirks() function pointer during xhci setup Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 04/12] usb: chipidea: imx: don't request QoS for imx8ulp Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 05/12] usb: cdns2: Device side header file for CDNS2 driver Sasha Levin
2023-07-24 4:08 ` Greg Kroah-Hartman
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 06/12] gfs2: Fix possible data races in gfs2_show_options() Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 07/12] pcmcia: rsrc_nonstatic: Fix memory leak in nonstatic_release_resource_db() Sasha Levin
2023-07-24 1:34 ` Sasha Levin [this message]
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 09/12] Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_ready_cb Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 10/12] drm/amdgpu: Fix potential fence use-after-free v2 Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 11/12] ALSA: hda/realtek: Add quirks for Unis H3C Desktop B760 & Q760 Sasha Levin
2023-07-24 1:34 ` [PATCH AUTOSEL 5.4 12/12] ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724013426.2333833-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=gustavo@padovan.org \
--cc=jiangzp@google.com \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox