From nobody Mon Jun 8 08:35:27 2026 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FEB23594A for ; Sun, 31 May 2026 00:13:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780186411; cv=none; b=PM+9hagoS2vl/Cog6X6fUCdi/3Z4iP0JWH+TP8obM1GLu9jWgfP+TgqZTgqkfzCD/bSRNjp/LwN9CRiFXuh8YXmI5OjhaTd47N+Ax8/pZqCaVRKnpnt9Ns7monYxSFgRbwjchIXLepgqTIutOWFY0P3XysFQk9CMjQPn3pxJcXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780186411; c=relaxed/simple; bh=iN8yt+9607Juag+rcG2cTPuMXda3FZX/wZ1SEqDJlcU=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=GAAQgRd00IIglzF+fx7l6gJ+eKBksrrGxQXmp/ywfz3R575DSoJwRd+PamGc06ZCCPz8ADnn4eDd2+alW+gCkgiCPoG7gdxuFVxPuF7IHZ/NcKDsVfoRFeCG89hiFoGMmJjIBX3pECOeZHVbbIt0QZMTEOM7n5RTI0dzS1pyl9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.160.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-43cabbedc29so1056477fac.0 for ; Sat, 30 May 2026 17:13:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780186409; x=1780791209; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uO5Bey+8bSJFbkLKqISTbFc/2wSashoAaL0U/rkrAqQ=; b=JUuLUXNU+Gz+sEMKGhfZG3l42SX8YCJYScHrog1/Oh8XxYJ3XJd3byQoZ7GreFO3VD OlaxMEYfsQqgWZlLM2F7qOKBdXs6IAIYtMo3r93RqqFs7ZlKiIUz2lZYj5DQ4+R9mtzt 1RG33Db8xhd/Zv9h9XfBU9iU4b40T5NBRYAECo5ik91Yx4+QyP53unuYvAXo4/WqNnZc SpQJhZz0MAsjaFwXilZza/H6X+skI+13JXp84fuACZCq+uXQfdxBD2AMZq1Zm+0CeDQG v2sw5O2MZZtMWgeCilAF/D8ISiN1TJTwIhrUxLnz5noO3oH0q3g8DlmD0WWcBj3AJg4i H/HQ== X-Gm-Message-State: AOJu0Yx4Dqfy9fwnQ3oPC6zxr8cethZ8eogHQQcy4uGa1yD41UGxGHlx +pwadAVtcdz3SmQ8vLNKXJYONhCrv2JIbuW4XC1Sjw19dcFbxs1g8yvkVmUf01lzr7mYo1VEkiq btPK46GwfJ2pgU/jQVk8EadZBQr4fIeoKN38Ycd8rbARn6NVkZ87tOq+enSs= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:f027:b0:69d:8efe:ce51 with SMTP id 006d021491bc7-69e043bdce2mr3784626eaf.29.1780186409595; Sat, 30 May 2026 17:13:29 -0700 (PDT) Date: Sat, 30 May 2026 17:13:29 -0700 In-Reply-To: <6a1b4f33.fbc46276.d3ed.045a.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a1b7d29.fbc46276.d3ed.05e4.GAE@google.com> Subject: Forwarded: [PATCH] Bluetooth: hci_core: Fix SRCU leak when device is freed unregistered From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] Bluetooth: hci_core: Fix SRCU leak when device is freed un= registered Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master hci_alloc_dev_priv() initializes hdev->srcu with init_srcu_struct(), but the matching cleanup_srcu_struct() is only called from hci_unregister_dev(). A hci_dev that is allocated and then freed without ever being registered leaks the SRCU internals - the node array and the per-CPU sda - even though the hci_dev itself is freed correctly. This is reachable from the hci_uart line discipline. h5_open() (used by the HCI_UART_3WIRE protocol) sets HCI_UART_INIT_PENDING, so hci_uart_register_d= ev() returns early without calling hci_register_dev() and HCI_UART_REGISTERED is never set. Registration is deferred until the three-wire link is synced, wh= ich never happens over a bare pty. When the tty is closed, hci_uart_tty_close() finds HCI_UART_REGISTERED clear, skips hci_unregister_dev(), and calls hci_free_dev() -> hci_release_dev() -> kfree(hdev), orphaning the SRCU allocations. kmemleak reports only the SRCU sub-objects, not hdev, confirming that hdev = is freed while its embedded srcu is not torn down: init_srcu_struct_fields+0x2c0/0x350 kernel/rcu/srcutree.c:207 hci_alloc_dev_priv+0x37/0x680 net/bluetooth/hci_core.c:2453 hci_alloc_dev include/net/bluetooth/hci_core.h:1763 [inline] hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:644 [inline] hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:720 [inline] hci_uart_tty_ioctl+0x173/0x460 drivers/bluetooth/hci_ldisc.c:774 Pair the SRCU init with destruction by calling cleanup_srcu_struct() from hci_release_dev(), so it runs on the final put_device() regardless of wheth= er the device was ever registered. Keep synchronize_srcu() in hci_unregister_d= ev() to drain readers walking the device list before the device leaves it. Reported-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D535ecc844591e50588a5 Signed-off-by: Deepanshu Kartikey --- net/bluetooth/hci_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 28d7929dc593..2d516beedb59 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2664,7 +2664,6 @@ void hci_unregister_dev(struct hci_dev *hdev) write_unlock(&hci_dev_list_lock); =20 synchronize_srcu(&hdev->srcu); - cleanup_srcu_struct(&hdev->srcu); =20 disable_work_sync(&hdev->rx_work); disable_work_sync(&hdev->cmd_work); @@ -2737,6 +2736,8 @@ void hci_release_dev(struct hci_dev *hdev) kfree_skb(hdev->sent_cmd); kfree_skb(hdev->req_skb); kfree_skb(hdev->recv_event); + + cleanup_srcu_struct(&hdev->srcu); kfree(hdev); } EXPORT_SYMBOL(hci_release_dev); --=20 2.43.0