From nobody Wed Apr 1 09:46:38 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 87A213E8C61 for ; Tue, 31 Mar 2026 14:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774966435; cv=none; b=VShLyU7LCrS1sRiGFjpphCIeCbEhiT+8JhiEoDLCAW1sQZ57Ryv4a3hatqrpCDXZOorAvR6oSSrQMjOXfLn4wB70HxiMlv9YmwD4FQEi6GWSNeSUauSwl+RTf6NOPDPuBet9s9bqPjuSBYlV43Y2p8a65Pi9JzL+iafDhfocevE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774966435; c=relaxed/simple; bh=szt0w8DbKoVg8ulmw8/DZSgLzId9BVRNgZALH0Fp2+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fCNrUXIgKIG1PosfRi+OWvaIMjUoftgjRS33qoYy2NoVwvkh2gDfToiLUZk5imxiwWn+qYOHAvUvr+VvoCdsEuX8GSqDH2GZp0V5rGHVwGzIS4zI8NzqLL2kCh89ti4wz5Dv9F48x3VJ8kQnidAXvKDyhqw0xTZI/qu0c9GB8e4= 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=F2Vk1FjD; arc=none smtp.client-ip=209.85.210.177 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="F2Vk1FjD" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-824c9da9928so3639104b3a.3 for ; Tue, 31 Mar 2026 07:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774966433; x=1775571233; 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=gEznFt8iy4PfjJKzwmf2yqiGR9CX0VFuj03I+QP2lL4=; b=F2Vk1FjDTzGMeJEBLL5KZvhExnhpcxoYDh7jRxljDbOoJQDCtRLux08bljbzY2LbWk D64np2pqqgfEu6GSGXBjFWBXGgqeaUWAlsL1yOP8zsVTdgZ/Nf5rwR5BgBEyFqyorrff Q4Q0KUrJntSqpjZhqVtBGoI+g/Y1uHyfTQ3rmpL7QLkewfQL8gvD2LZX8KaQ5VbQ8gh1 xnJRNhkLpx9M0Vdo/LIcUIjjO+ZoGvENH7uv6RGGTEcsljDFXBxeiPj6TXC/3ZRzv9oG 3pCLeSfqANiQCrzq6Yd5jxSpI/a5NeHaLpraCfI1qndQRvgN1sS0p5I4D/aj3XQs2rBC pyEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774966433; x=1775571233; 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=gEznFt8iy4PfjJKzwmf2yqiGR9CX0VFuj03I+QP2lL4=; b=UCJ7PyzJko8MsqxuWqOBdYeFwotsF6kjD9PbacMXx17xLedJSYZOuKVzfKWTzBNyYw mEJ8al4FBbFy0VznTyi3X70uFIX8o7nqplRRQQ40Y7cwcAjwlGUja4eCQsOcp5Aaht1n k1fc4OumDuzkEUN7aQo9oLrPkUKy2eA2a0SY98dZKqMIr6XyGrZIjYQoz8/hoBuHbKu4 214DMOelhOByo2LD33AvBYgOneStrZzs7+pfdqw+2qgpyA2iq9UHV/3ULHFRtzfrH/w8 LP7AIJ7yDaIkNURzGePXO4ssOBdQJ/MfPagSHMJBKMx+DxMbi8Ed9qAUxcZIG+SwdYOC S8pQ== X-Forwarded-Encrypted: i=1; AJvYcCWMFV36Ow6n3zDk9/tuwcbh7yeT4AjFJO1kKHv1jGy5a91hOmt0rSzbINEIgoNT8yb0rB4/z5kHiVKHnsY=@vger.kernel.org X-Gm-Message-State: AOJu0YzITsLIFa/C3wdAbxuVKASO8azP84GtoCzEQUnpzY7dzvKqAEIZ N3R1xdOQUcUXDyE/G9W4rpuouDZz/OURY3/ZZCG3N5DUCJ9YsdW4Wx+O X-Gm-Gg: ATEYQzzAS52aks6J9Zc4+BBivaduTyT5560tEzfdXl8C3hds1ViLY2AicHygrbiqGOA AoRUAhuzic2nCdsd1tOa4ogwsBrlVnDaanrnri6K/wp6dzNLTj3Qsi/Kltt5vEcftT1zsOBvnm+ mGWjcK2o6WbC86aqhkmCqsxdBKxHq3g+2a8qD3Qv85Of7y3jcRz5Tw64RuT+c9wTnskKKwnukL9 hnVuhmHj/JYKp0glghTVOTKUty0D3id3bN8CoJ8/OK54RPIkAjOW/3XU95vQPmgbhofBgmnen8Y OIp0VpxaZV5+sVa33H/EY5g81es/KqvMV7BPbkBsyEg6yVoAkfUUHIFtwghfIznaLEAyUCuHuPx LvploXpWWkLBQ+XSbmoU8gnUB+5oxFB4iaCnI97I7MF5LYAr+NmchlJUd19P1FxD6yUMmvVQN4N iR4g4u X-Received: by 2002:a05:6a00:6ca2:b0:829:6f7d:3093 with SMTP id d2e1a72fcca58-82c960942d4mr15021120b3a.48.1774966432737; Tue, 31 Mar 2026 07:13:52 -0700 (PDT) Received: from hkbin-u25 ([2406:280:1003:25b6::6da]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82ca847ff4dsm10630221b3a.23.2026.03.31.07.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 07:13:52 -0700 (PDT) From: hkbinbin To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: gregkh@linuxfoundation.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, hkbinbin Subject: [PATCH v2] Bluetooth: hci_event: fix OOB read in hci_le_create_big_complete_evt Date: Tue, 31 Mar 2026 14:13:32 +0000 Message-ID: <20260331141332.3243059-1-hkbinbinbin@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260331055032.1883139-1-hkbinbinbin@gmail.com> References: <20260331055032.1883139-1-hkbinbinbin@gmail.com> 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" hci_le_create_big_complete_evt() iterates over BT_BOUND connections for a BIG handle using a while loop, accessing ev->bis_handle[i++] on each iteration. However, there is no check that i stays within ev->num_bis before the array access. When a controller sends a LE_Create_BIG_Complete event with fewer bis_handle entries than there are BT_BOUND connections for that BIG, or with num_bis=3D0, the loop reads beyond the valid bis_handle[] flex array into adjacent heap memory. Since the out-of-bounds values typically exceed HCI_CONN_HANDLE_MAX (0x0EFF), hci_conn_set_handle() rejects them and the connection remains in BT_BOUND state. The same connection is then found again by hci_conn_hash_lookup_big_state(), creating an infinite loop with hci_dev_lock held. Fix this by: - Breaking out of the loop when i reaches ev->num_bis and cleaning up all remaining BT_BOUND connections, then terminating the BIG since a mismatch between the host and controller state indicates failure. - Properly cleaning up the connection when hci_conn_set_handle() fails, instead of calling continue which leaves it in BT_BOUND state where it would be found again by the same lookup on the next iteration. Fixes: a0bfde167b50 ("Bluetooth: ISO: Add support for connecting multiple B= ISes") Cc: stable@vger.kernel.org Signed-off-by: hkbinbin --- net/bluetooth/hci_event.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 286529d2e554..64b5b497c491 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -7085,9 +7085,15 @@ static void hci_le_create_big_complete_evt(struct hc= i_dev *hdev, void *data, continue; } =20 + if (i >=3D ev->num_bis) + break; + if (hci_conn_set_handle(conn, - __le16_to_cpu(ev->bis_handle[i++]))) + __le16_to_cpu(ev->bis_handle[i++]))) { + hci_connect_cfm(conn, HCI_ERROR_UNSPECIFIED); + hci_conn_del(conn); continue; + } =20 conn->state =3D BT_CONNECTED; set_bit(HCI_CONN_BIG_CREATED, &conn->flags); @@ -7096,7 +7102,22 @@ static void hci_le_create_big_complete_evt(struct hc= i_dev *hdev, void *data, hci_iso_setup_path(conn); } =20 - if (!ev->status && !i) + if (conn) { + /* More bound connections than BIS handles reported by the + * controller -- treat this as a failure for the entire BIG + * and clean up any remaining BT_BOUND connections. + */ + do { + hci_connect_cfm(conn, HCI_ERROR_UNSPECIFIED); + hci_conn_del(conn); + } while ((conn =3D hci_conn_hash_lookup_big_state(hdev, + ev->handle, + BT_BOUND, + HCI_ROLE_MASTER))); + + hci_cmd_sync_queue(hdev, hci_iso_term_big_sync, + UINT_PTR(ev->handle), NULL); + } else if (!ev->status && !i) { /* If no BISes have been connected for the BIG, * terminate. This is in case all bound connections * have been closed before the BIG creation @@ -7104,6 +7125,7 @@ static void hci_le_create_big_complete_evt(struct hci= _dev *hdev, void *data, */ hci_cmd_sync_queue(hdev, hci_iso_term_big_sync, UINT_PTR(ev->handle), NULL); + } =20 hci_dev_unlock(hdev); } --=20 2.51.0