From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AA3015012A7; Tue, 13 Oct 2026 12:07:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791893247; cv=none; b=Vj+ihdWo+OJ8vIcgFIpFqDDxh+as5KZJik+TUPUCjQomm4lTGTbsvsVmmN1MIqypU//cToK1klOyPTUAq8OMuUnvbtEiB3u8tc1f7kj1Ifm0V5v/T/ymMUnH9DTCwtV8qvHtj8nyoLh2D8AT3mX8cK9LsW2cZIXqEkwTE671E6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791893247; c=relaxed/simple; bh=5Duyyzd1aMJ4w4ZNfgU2m7X0OlJkUb6Jp1hu4PE84Y8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OYCD7HR629yMBzl9p/nC57h5dK8buZGgbtMt5epNe66TVQuYupiVniY1WbVb9h9eL0Brwcc8e8mM52+RfPv3yDq3OtZ63XyfkSNfg491Y5NZb49FOwyzvEvq8O/5n2g81JNLYzEQuZk1q4NioIn2b3HnD4CU/uWqM+uq5nhpwug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jtOlFvKB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jtOlFvKB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BB221F000FF; Tue, 13 Oct 2026 12:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791893246; bh=vI6QKwL6g9HcfUWKZGZ/MYOsxd5Cxagvd0DYOHGJBf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jtOlFvKBLDTXqsbw8ihF4XgLqbcBQXSG2EL/HiVcKoba3Zy3ZBUJuLTJA1Mxs0k5u 3+tq39b2fOkaWkHyP1Ti8r0r++nlWq2NGWL4DfeG8z+E+7kviIcBZi4c/5n/ysKO/p av6PfqWp3e0pGyIhco+V1p5KlIoX7BlOuQmaI1TQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikhail Gavrilov , Maxim Skokov , Luiz Augusto von Dentz Subject: [PATCH 6.18 108/621] Bluetooth: RFCOMM: free the skb when the DLC has no owner Date: Tue, 13 Oct 2026 13:31:43 +0200 Message-ID: <20261013112923.413539086@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112920.855194808@linuxfoundation.org> References: <20261013112920.855194808@linuxfoundation.org> User-Agent: quilt/0.69 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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maxim Skokov commit 9d1afbf60ed53c5b051cd124153e0ae3078c8b93 upstream. rfcomm_recv_data() hands the skb to d->data_ready() and returns 0 without freeing it, so the callback owns the skb from that point on. The tty implementation frees it when the DLC has been detached from its device: static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) { struct rfcomm_dev *dev = dlc->owner; if (!dev) { kfree_skb(skb); return; } The socket implementation returns without freeing it, and the skb is leaked. A connected DLC can have no owner: rfcomm_sock_destruct() clears d->owner, while the DLC itself stays on the session until it is closed. Data frames that arrive in that window still find d->state == BT_CONNECTED in rfcomm_recv_data() and are handed to the callback, one leaked skb each. The leak does not stop on its own either. The remote runs out of credits only once RFCOMM_RX_THROTTLED is set, and for a socket the only place that sets it is rfcomm_sk_data_ready() itself, below the return. rfcomm_process_dlcs() keeps granting credits, so the remote keeps sending and the leak keeps growing. Free the skb, as the tty side does. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Mikhail Gavrilov Closes: https://lore.kernel.org/linux-bluetooth/CABXGCsPe5wykd8Aj-hm+SJ7SGQyb8yoGNnx3XDpPmBathj+EGg@mail.gmail.com/ Cc: stable@vger.kernel.org Signed-off-by: Maxim Skokov Assisted-by: Claude:claude-opus-5 Reviewed-by: Mikhail Gavrilov Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/rfcomm/sock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -50,8 +50,11 @@ static void rfcomm_sock_kill(struct sock static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb) { struct sock *sk = d->owner; - if (!sk) + + if (!sk) { + kfree_skb(skb); return; + } atomic_add(skb->len, &sk->sk_rmem_alloc); skb_queue_tail(&sk->sk_receive_queue, skb);