From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384380; b=Wyy53LtLqvyB1tC8lG8VkIPmjdpNQpw2URaK8Uo6GfPQWdVjpS+ZynkF8pKC0pu8Rfta KCJKZcPZs0FcrIEqP8nsuvq79K2XqphFXPTpvAou5YHmdygBY3xvyt2fYi6xF3wVluKXJ Uhy9WV/VAA9PSpRE9W3XUd1J1ENPF8Ud7k7oUZ1jiEHlvm6vLiCdGPEdDC4ry2qPGe8EM +15HhA9eZlleIb/h/5DHJDG0VT/LY+XzI7xOzd7ps6d2OhoEWX5yAYGsYzGSGwhDagw89 aHVgQ+BSLQ5fvY/H3nZtRvN7e3+tHlEuJPbj6eA9unC1eTX5B0DkcrpWrCVXs2f04uw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384380; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=GpsYCXSpWC9Z1bxdhJKJFEiefax/dw/PgypS08bNrwE=; b=auWc+tOfQr5GqHgWaekNvPVId4HbgiATSjDYUMzA5a+XgsPnQ3d2IJ5o/L3iSfPbI4ZK iGQgdHO7rUdYN2h0POb0IWcaMoyNbZzv15GEBtMRt8A7pJxYUKTx/UwWsdn2QYnwQZ6Dn GJ6fSHtjerhr4T+zpV80oozj/GXe0jB6OQftBptEjvJUccIqgt+SiILUEpiYfsLHW2k4M JJ2o7hpwuFye01dWhHbz97s354SISnuBhSb5oW6fNRGQrjewAdfauS5kxxYv1CISjcC/y c20XjdyQYNGiI5XlvaEwbZrNAwMq2DNEb/ZYotPBaRLx5OfYpYVV4Yu4fcQ3l5bvoOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f9gWSbZx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87B78606A32D; Fri, 4 Dec 2026 11:39:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f9gWSbZx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69EFB1F000CE; Fri, 4 Dec 2026 11:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384379; bh=GpsYCXSpWC9Z1bxdhJKJFEiefax/dw/PgypS08bNrwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f9gWSbZx5obzv6gCRDnb3WqwwSahpAgigkBewXYJ7BD2RPAnY8a59UAylmYdkb7AZ +QVH3e1j3uUIsfKufscf3sYXE0PtbTG25IfffovDXwl3z13xvGfximWtyii4n/MU6r JdvkDJMaRFJAdQnLgAEg9TV0WOBHXbv+ARDo0nA4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cen Zhang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 0125/1167] Bluetooth: hci_core: Initialize advertising RPA work only once Date: Fri, 4 Dec 2026 18:52:32 +0900 Message-ID: <20261204100705.342689388@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cen Zhang [ Upstream commit a7c5c18b7cc30dcd2a9ae5a0fb38378d3998417e ] hci_add_adv_instance() also updates existing instances and calls INIT_DELAYED_WORK() on their rpa_expired_cb every time, even when the work is pending or running. cancel_delayed_work_sync() then no longer finds the work, so hci_remove_adv_instance() can free the instance under it: hdev->workqueue MGMT_OP_ADD_EXT_ADV_PARAMS adv_instance_rpa_expired() hci_dev_lock(hdev) hci_add_adv_instance() INIT_DELAYED_WORK() mgmt_pending_new() fails hci_remove_adv_instance() cancel_delayed_work_sync() returns without waiting kfree(adv) hci_dev_unlock(hdev) adv->rpa_expired = true The work has been initialized on every update since it was added. Initialize it only when the instance is allocated. KASAN report as below: BUG: KASAN: slab-use-after-free in adv_instance_rpa_expired+0x139/0x160 Write of size 1 at addr ffff888108d84b2e by task kworker/u17:0/504 Workqueue: hci0 adv_instance_rpa_expired Call Trace: adv_instance_rpa_expired+0x139/0x160 Allocated by task 560: hci_add_adv_instance+0x68d/0x9d0 add_ext_adv_params+0x4d4/0xb60 hci_sock_sendmsg+0x128b/0x22e0 Freed by task 594: kfree+0x307/0x580 hci_remove_adv_instance+0x230/0x540 add_ext_adv_params+0xa43/0xb60 hci_sock_sendmsg+0x128b/0x22e0 Last potentially related work creation: insert_work+0x37/0x210 __queue_work+0xaba/0x1270 call_timer_fn+0x171/0x500 The buggy address belongs to the object at ffff888108d84800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 814 bytes inside of freed 1024-byte region [ffff888108d84800, ffff888108d84c00) Fixes: a73c046a2869 ("Bluetooth: Implement Set ADV set random address") Signed-off-by: Cen Zhang Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index d5aeede6c623f..eaceb86b5c3cd 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1719,6 +1719,9 @@ struct adv_info *hci_add_adv_instance(struct hci_dev *hdev, u8 instance, if (!adv) return ERR_PTR(-ENOMEM); + INIT_DELAYED_WORK(&adv->rpa_expired_cb, + adv_instance_rpa_expired); + adv->pending = true; adv->instance = instance; list_add(&adv->list, &hdev->adv_instances); @@ -1746,8 +1749,6 @@ struct adv_info *hci_add_adv_instance(struct hci_dev *hdev, u8 instance, else adv->duration = duration; - INIT_DELAYED_WORK(&adv->rpa_expired_cb, adv_instance_rpa_expired); - BT_DBG("%s for %dMR", hdev->name, instance); return adv; -- 2.53.0