From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Sungwoo Kim <iam@sung-woo.kim>, Sasha Levin <sashal@kernel.org>,
marcel@holtmann.org, johan.hedberg@gmail.com,
luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 27/29] Bluetooth: L2CAP: Fix user-after-free
Date: Sun, 9 Oct 2022 18:23:02 -0400 [thread overview]
Message-ID: <20221009222304.1218873-27-sashal@kernel.org> (raw)
In-Reply-To: <20221009222304.1218873-1-sashal@kernel.org>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 35fcbc4243aad7e7d020b7c1dfb14bb888b20a4f ]
This uses l2cap_chan_hold_unless_zero() after calling
__l2cap_get_chan_blah() to prevent the following trace:
Bluetooth: l2cap_core.c:static void l2cap_chan_destroy(struct kref
*kref)
Bluetooth: chan 0000000023c4974d
Bluetooth: parent 00000000ae861c08
==================================================================
BUG: KASAN: use-after-free in __mutex_waiter_is_first
kernel/locking/mutex.c:191 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common
kernel/locking/mutex.c:671 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0x278/0x400
kernel/locking/mutex.c:729
Read of size 8 at addr ffff888006a49b08 by task kworker/u3:2/389
Link: https://lore.kernel.org/lkml/20220622082716.478486-1-lee.jones@linaro.org
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/l2cap_core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 442432f89be1..2d28b4e49b7a 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4066,6 +4066,12 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
}
}
+ chan = l2cap_chan_hold_unless_zero(chan);
+ if (!chan) {
+ err = -EBADSLT;
+ goto unlock;
+ }
+
err = 0;
l2cap_chan_lock(chan);
@@ -4095,6 +4101,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
}
l2cap_chan_unlock(chan);
+ l2cap_chan_put(chan);
unlock:
mutex_unlock(&conn->chan_lock);
--
2.35.1
next prev parent reply other threads:[~2022-10-09 22:55 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 22:22 [PATCH AUTOSEL 5.4 01/29] wifi: rtw88: phy: fix warning of possible buffer overflow Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 02/29] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 03/29] bpftool: Clear errno after libcap's checks Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 04/29] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 05/29] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 06/29] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 07/29] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 08/29] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 09/29] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 10/29] net: lantiq_etop: " Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 11/29] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 12/29] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 13/29] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 14/29] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 15/29] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 16/29] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 17/29] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Sasha Levin
2022-10-10 13:33 ` Vladimir Oltean
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 18/29] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 19/29] wifi: ath10k: reset pointer after memory free to avoid potential use-after-free Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 20/29] can: bcm: check the result of can_send() in bcm_can_tx() Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 21/29] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 22/29] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 23/29] wifi: rt2x00: set VGC gain for both chains of MT7620 Sasha Levin
2022-10-09 22:22 ` [PATCH AUTOSEL 5.4 24/29] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 25/29] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 26/29] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:23 ` Sasha Levin [this message]
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 28/29] libbpf: Fix overrun in netlink attribute iteration Sasha Levin
2022-10-09 22:23 ` [PATCH AUTOSEL 5.4 29/29] r8152: Rate limit overflow messages 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=20221009222304.1218873-27-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=iam@sung-woo.kim \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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