From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 D0DA53FD152 for ; Mon, 11 May 2026 14:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778510074; cv=none; b=tWb3g6cafNXY8aZFpd4FbmM/sy13YXx0EXONXB2feb013NL0qwc8JAvT8SwOMtlpIlF3Mae9ofmtrxPgFl70HJt/NWB/ZGjXn5LyAop3r87k4u78cAGa6P4zmNjAJ/aqshVimTebFTAtjcWKYnrYv3O+4kWi4ECXonQiieKu/TI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778510074; c=relaxed/simple; bh=e2R8DBscIk19IhJxMXZPQpQwLfnAMEQ7rmfH0FSfdQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fUN6XchBcij+1GuRqWP3ZhpXtdZAfn6tQQ/bE/DWCtJ5SqFpCc7QdBC7hvbOuiyCg9375NZRApI+HpqGdFT47cW8RIqBkcLdtJNInOCgQuSejiIX8AYFJmXErOYk2hZcSppnkIPKnkPq9kNtatIYOl7ZFwelC62ENrp1SOPq1uU= 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=oxmlJzf0; arc=none smtp.client-ip=209.85.160.176 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="oxmlJzf0" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-50e63771d91so45287391cf.0 for ; Mon, 11 May 2026 07:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778510069; x=1779114869; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HCibvydRPttcdEiskE4PpFNMkbJQi5uTd3rinfvp+sU=; b=oxmlJzf0xewfTMPsqupr+ly44IVcQ+TzJLytQe5KFk2ER+2d7xrGPmI7DKSd/Rqm9c +gK+2SU7HdXIQSmBGELR8T66XJvoyL9DYA0rQXvpMlLGb/+Zf69BeQNTLofSMPXhs+3s ulCJCJN7kPc3hQxcJE/eOLY/swQsyaJxt+wPmFYLFTvx/dZF3c7dkvmC8r648OSJuCtq Kl4U7Mga9XKEUCFhEynyWoqCX4+j5mxIATj2mCaVRW9XggTL2DpcwBOD1eh9A9aBEME8 tn/RtMzizgaWbj4JM7UgRECUTTbGdRk6tRiZcU7rGAiWPuGxkzxlw1T2DqdY9OoRtHEx ZW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778510069; x=1779114869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HCibvydRPttcdEiskE4PpFNMkbJQi5uTd3rinfvp+sU=; b=EGEP0hIUnJn4goJKu9INIVGo0K46QMGjI0DplLkKM5VCILQI+MlJMo5g+BSLyx/7jq XfPYZciM+/39p9oSdtnpEZCUlYfiHFcJqmEahN51XGMmbzaBCiaWgHcIWKtY6NdmRJEm A2u4I0+AMoXm5V/IHYujwZ27hIxeLOI20zqdvo10vTuAGMFAFYkOQ/BQfwC1YAiup0om w+n64F2OGqdCMlAUjgyX7/UyLxwLscpO9x1ib7la6e5+Z3EjhXNSw2VwkGUAWEJ47JAs q1Pymgls1LNh6VeiOyfbtl97+/txsZ2uT8hC4Y+Yn2+XLYBGYmACS6AXIpfp0GXifpyi n5CQ== X-Forwarded-Encrypted: i=1; AFNElJ/bXQhZZCSzZby4Ubn6pdqbYuBvlIHOaaXV7vC7WkZSyzBn2/KAwAd+kggjklyIB3jNcRJdwQMFBQiJ/Lk=@vger.kernel.org X-Gm-Message-State: AOJu0YxiroUmQfX4kKUxLuELBqDQylbnHOHqu5ikBNqCf1dn3n2XjX0U 2U8XFb4JN9EMGjhJcivzwhH1XfYF1/hHrizm23jLfp+Qnksb/ZOmwHQO X-Gm-Gg: Acq92OEjswEkNGz1Cy2VOyScGWJfHNjHohFSsRAa7yhYLJIWkPxI/3tnIZnsyZYy9eT En3G1zICUKJ0E+WaM7MIHWDlK0W1+DHA4TwnX+SLx5J0AMKV0W3oFb9oOk4zUMEu1h8NcAolo0f h4I6sA/XTJzRL8dqpD47tHxxTfNpUB8+NV5gwOEjlE36TYJJdLQUW0UvgY9o3VuvHuAYmjYH3ki vcnqtveInDO+LY52ZRwNO6PVIeLuVSPGWaCP0QYIexC9eNJli6P2zOU/511QfFn4ZQaDHpUgwwN 8R9BGP/Zkk+GB5kdV99+Pmvvi187FIzMyl57ZAG03CS6i7Xwi/sqmWVhmsl3nzxGkUEbNHx2yqv uu1azFObZI12xyq5a6QDPLtA/kYiaFr+FxkDlktUznlWk8zUSfWTfdAD2lSI3f68Phmo/A/sq7M +NpbHyjPP7/Kb9VDxZHZPN8uwKc6qbCj0T1cjhprZaQ8MYBopUCTjYwz3+BuWytkaCtvv46Z9vv qCoEzOR9KVjEZIn4m986TaUzJgqpGnwif4l7Ups+gcHXbOETUA9Pw== X-Received: by 2002:ac8:5783:0:b0:50e:6054:b4 with SMTP id d75a77b69052e-514a0a2a3b1mr143979381cf.7.1778510069079; Mon, 11 May 2026 07:34:29 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5148e83aa2bsm90605371cf.28.2026.05.11.07.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 07:34:28 -0700 (PDT) From: Michael Bommarito To: Marcel Holtmann , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mat Martineau , netdev@vger.kernel.org, stable@vger.kernel.org, Pauli Virtanen , Aaron Esau , Michael Bommarito Subject: [PATCH 3/4] Bluetooth: hci_sync: pin conn across hci_le_big_create_sync Date: Mon, 11 May 2026 10:34:03 -0400 Message-ID: <745aa080da109c4a698a3f1478b3f08e53f2d4d8.1778506829.git.michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hci_le_big_create_sync() interprets its void *data argument as a struct hci_conn pointer and dereferences conn->iso_qos, conn->sync_handle, conn->num_bis, conn->bis, and conn->conn_timeout after the entry hci_conn_valid() check. As with the sibling cmd_sync callbacks, hci_disconn_complete_evt() can retire the conn between the validity check and the body's first deref, and the blocking wait for HCI_EVT_LE_BIG_SYNC_ESTABLISHED extends the race window to seconds. A KASAN slab-use-after-free splat in cache kmalloc-8k at conn->flags (set_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags)) confirms the bug on linux-next tip commit bee6ea30c487 ("Add linux-next specific files for 20260421"). Convert hci_connect_big_sync() to the hci_cmd_sync_queue_conn_once() helper and balance the conn pin in create_big_complete()'s -ECANCELED short-circuit. Promote create_big_complete()'s hci_conn_valid() + clear_bit() pair to run under hci_dev_lock so that hci_disconn_complete_evt() cannot remove conn from hdev->conn_hash.list between the check and the write. Prior art: Pauli Virtanen's PATCH v2 8/8 at https://lore.kernel.org/linux-bluetooth/e18591f264c50e15917cb8b9e5f9798d9880979d.1762100290.git.pav@iki.fi/. Fixes: 024421cf3992 ("Bluetooth: hci_conn: Fix not setting timeout for BIG Create Sync") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Michael Bommarito --- net/bluetooth/hci_sync.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 43779375209b..47ce9ba63fe2 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -7265,10 +7265,16 @@ static void create_big_complete(struct hci_dev *hdev, void *data, int err) bt_dev_dbg(hdev, "err %d", err); if (err == -ECANCELED) - return; + goto done; + + hci_dev_lock(hdev); if (hci_conn_valid(hdev, conn)) clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); + + hci_dev_unlock(hdev); +done: + hci_conn_put(conn); } static int hci_le_big_create_sync(struct hci_dev *hdev, void *data) @@ -7320,8 +7326,8 @@ int hci_connect_big_sync(struct hci_dev *hdev, struct hci_conn *conn) { int err; - err = hci_cmd_sync_queue_once(hdev, hci_le_big_create_sync, conn, - create_big_complete); + err = hci_cmd_sync_queue_conn_once(hdev, hci_le_big_create_sync, conn, + create_big_complete); return (err == -EEXIST) ? 0 : err; } -- 2.53.0