From nobody Mon Jun 8 05:25:23 2026 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 E7D053FFAD6 for ; Wed, 3 Jun 2026 07:51:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780473118; cv=none; b=bOTKvYbjs3EKjCian62K7Sr0RBrGscCza9i1NgAaZKJ3kYomPC5lfZ8Tse2nNcUGV02GN59/gen0+Vqh096Qbz+IL4ja/eC96Wc0G2HK+zbZuE8+SZk+chY/4Ef/Z/2uahtN7IyA2GtA/AhsmJzK/Tdg6OC6pUMbDqjpghsrA/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780473118; c=relaxed/simple; bh=HFQnlyGMtu6XnVNHtVmKaEi9Si0QC6+UMnDjK0T/lJc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cwDqOva/yO9+JzFDAiW7yV5+60KEdN5Y0CDORKIK76MaMpN3gCrRcw2XBugkpjvYja+X+U1TqMG5txlxux5+y8Upaafe7PdCIuEsGGiSxw6wT/qpnrVP8YQXHIWTq9zZv6Db6qh99Vdw3LmCWXNkG1QzcUsTR7cki7UUIAgkVm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CyUnk0dZ; arc=none smtp.client-ip=209.85.160.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CyUnk0dZ" Received: by mail-qt1-f193.google.com with SMTP id d75a77b69052e-517760dc3c2so5731441cf.3 for ; Wed, 03 Jun 2026 00:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780473115; x=1781077915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FyGMsCURDgvAJb24/tJx3kSbx6+tiPPr8AW+9MPyDfk=; b=CyUnk0dZ12ymypXsDdyYAsrdil8JFjAAMoD448I1nYh9fQ+OsOTUDvr3jpE1X75+Sy hqdAOXom/Yfa2B8ATtDkxjpBoAcgqZVPrPWoXvj7bLuY/yCmM1vC6jU1a45ltKdS+ciq 8cn6POHI2Dc3GWVK5wfIqsJ8pbaMc6DjgGk2uJOXWjzyWWxlNaKZEWB/3hJNlJ3hw9sC Pg39jP5z+q0iI64ns3RWPLBGPYgp7DgocF9Cvgry8b0BqMBo1/2Xje7AknyDf663Pw0C 66utZ+gPoEhD4z+gcvtKwoNmLY3HiRC9f9C/8cnqHeFgyljoTJ3yxrZ5Y3GYPvYOwmgh 42pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780473115; x=1781077915; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FyGMsCURDgvAJb24/tJx3kSbx6+tiPPr8AW+9MPyDfk=; b=NXkI9gCIVPL16PmKUy30algGv2s1Q7KshESVYzPQ4qK0lKdg9X/0s6qd1VqErJSb6L BxgzGRV8sGTtqFPxshsPBhfoF/col1qVWA2kIXqSz34ALs3uJPwR5QRLfkRJ5E3x7soc ozYpTgmKt9luNClwKMvk3zOzHqLtsloGXHFN1t7S/FY4o1KUXLNwIt+93dAG5CKwxbaO tkIyH+plK894D5GFRObOL+NDFNgA9Yu6PKQqnpBVMz4RM9XJDgoyv4fGZTkLO7GVhqDh pE+QMVCUv2PDTsxQr6vI7XE0al4/8p89Hux10+D1sQG795mpWJHj2P60BKc9khp2yAXe UM7g== X-Forwarded-Encrypted: i=1; AFNElJ9pOdNscB06XW6X0DY6Rn9KKkYmeNteMf61A42vb+GtiP/rlr4iVmi9Ca7HY6wc9lY3Hj2Hkfib1tWbjlU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzlsm8jp+Hu41/pSndjgjnllIW/6FqzwjQTR/LUs0tf+nRNKFjN P6HFnP7LJZKDAilCYQ/OZVtQpXMbKrZtFZlrAyU+9MvmS8Ert7B0FrA= X-Gm-Gg: Acq92OGUPKilCY83612nC5i3WXyhNDs7L9KJ5Pxpi9ZX2ffUAF13QWbbPF1q5D2Ogx8 NqOWMD2vIU7uhvnWSVJcJyLPlL97fBTERE07sd+rKJAdj50lAD3lMMaVw+Ebt5w8AuAYYqfaHh2 UwgTl64C2Dv173EHjWBxoLDLiyFHHS/w7qC1eq0rRHXwc25L9PUaevOR5xydn1qXAtY32hS/8Em h2fUX0L2ajW5pVJV1TB0hG61uK+/+I+7Fjv6EXZCtz0OJt7gwhyjGxl5IKMM710Wydrobj/UEY8 K7Us+zoanp3QSeoAb0kxLvQHz4bTK3Iin1oL0soFKR4F8qYJrXg9TY2BOS9+QKbIMAThJX9Xm50 K94S/QnmNEEcAkKNDOPxMblIBIXiTYXp1pY4MpTPxa5ZLHmguPUlrHPQ3vjysKpVZVmqjJSuhPm PFdNeY/QUmmj19D7ELTfNwGhqZAuueUlRiDMeej5cBkozIk/B2eK4nF1/vf2eDYg4Nq0fG+HgNe Q== X-Received: by 2002:a05:622a:8c1a:b0:517:5969:570a with SMTP id d75a77b69052e-517786ca1d1mr32082341cf.43.1780473114673; Wed, 03 Jun 2026 00:51:54 -0700 (PDT) Received: from rainbow (static-68-235-46-233.cust.tzulo.com. [68.235.46.233]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775a2f5d7sm20292101cf.0.2026.06.03.00.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 00:51:54 -0700 (PDT) From: Jordan Walters To: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] Bluetooth: Fix Use-After-Free in hci_unregister_dev Date: Wed, 3 Jun 2026 03:51:34 -0400 Message-ID: <20260603075134.246832-1-jaggyaur@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hci_unregister_dev() function fails to safely cancel the cmd_timer and ncmd_timer before freeing the hci_dev structure. If an asynchronous event or timeout occurs during device teardown, the timer callbacks may execute after the device has been freed, leading to a KASAN slab-use-after-free panic. This patch adds cancel_delayed_work_sync() calls at the end of hci_unregister_dev() after all teardown procedures have completed. This ensures the timers are fully flushed before the struct is freed, preventing any use-after-free conditions. Signed-off-by: Jordan Walters --- net/bluetooth/hci_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 28d7929dc59..3db1b3738b5 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2698,6 +2698,9 @@ void hci_unregister_dev(struct hci_dev *hdev) rfkill_unregister(hdev->rfkill); rfkill_destroy(hdev->rfkill); } =20 device_del(&hdev->dev); + + cancel_delayed_work_sync(&hdev->cmd_timer); + cancel_delayed_work_sync(&hdev->ncmd_timer); + /* Actual cleanup is deferred until hci_release_dev(). */ hci_dev_put(hdev); }