From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 675B411C83 for ; Mon, 28 Aug 2023 10:24:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEFACC433C7; Mon, 28 Aug 2023 10:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693218242; bh=zXa9zoRQ3dvDeLOjpEOqg46YSKkNxRcjF2EqmY7rP5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rp4jQu38qpzyJKcrxv/4zlCAqGCaE4326Sh7GNqPKG6nujFbAwkckFLSLufj+M+F9 G3drQbx8scB7+t0xCalK1YdOzcRqBhvRgJLnc7706nYvY8jdojV9eDSzcsOYZ54mOZ /U2Wk++rntfpGHU+UXBXgDrgkdmQuetdg430GyVM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhengping Jiang , Luiz Augusto von Dentz , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 017/129] Bluetooth: L2CAP: Fix use-after-free Date: Mon, 28 Aug 2023 12:11:51 +0200 Message-ID: <20230828101153.694433600@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101153.030066927@linuxfoundation.org> References: <20230828101153.030066927@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhengping Jiang [ Upstream commit f752a0b334bb95fe9b42ecb511e0864e2768046f ] Fix potential use-after-free in l2cap_le_command_rej. Signed-off-by: Zhengping Jiang Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 fcc471f921895..9346fae5d664b 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -5705,9 +5705,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