From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 162B03AE198; Fri, 4 Sep 2026 05:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499277; cv=none; b=URESBotf2XkBRP/hsZLQaTMsqA0nnprMbGtKX+JaeerhffgJZckAiJ3nu5h8FX3s6wJ7QNtsmJCOKdpDMc4qXYVl6eHASFhoTzqjPpnHwbwnFIA5VSj4coVx1UWXKU8WollEVZ2oMkCecQPJz+fPHsjtlR7SBC4QFrOgoNf1LO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499277; c=relaxed/simple; bh=dYvxsUllqSqYXoKkEKcVCP9y4etI0g73TyTkoC/oIns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvRWcLtjPXOAIr7c3sAUvVuSeA8em2umhbOecKcVmZL1iSd6c2F0+lWN/0AMbpsmQIu+BxihQZCLrC/k5Jdw23/3c/bq8Wgt75QSbmQ+nXeG14PHhl1CbnZJ+nrCTaszYob7Q3hnflBzuMKP++w2GZ1VbW+0dzGdR3hikmBhxiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CiKRo7jw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CiKRo7jw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6628B1F00ACA; Fri, 4 Sep 2026 05:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788499275; bh=4vLXgQSUzzkuj+udc3GMW3ZaSYwjUe4DBjb+8xCAedM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CiKRo7jwHmBPYfk5L8AFTO2HG4DRq0ZkBhug4VdAfhKq1URFqJZJNKCdWEJCWqZxp xQXQdbxhy01ogFRjXs3ip9agmBJHvUP8CgjVEXgyqR1l2SJ0sVbtqFwEEZuqddZEEk PCZzAh/qsLlCv1rPGP9fyVYe/wdGuq3oTbjE/aAg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, HyeongJun An , Luiz Augusto von Dentz Subject: [PATCH 7.2 317/713] Bluetooth: eir: Fix OOB read in eir_get_service_data() Date: Fri, 4 Sep 2026 06:54:45 +0200 Message-ID: <20260904045810.936736697@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: HyeongJun An commit 4beb198bc59b242404a47c21990bc84165052c8a upstream. eir_get_service_data() walks the advertising data for a Service Data field with a matching UUID. On a mismatch it advances: eir += dlen; eir_len -= dlen; eir_get_data() reports dlen as the field's data length, but the field spans dlen + 2 bytes once its length and type bytes count, and more when non-Service-Data fields were skipped to reach it. The pointer lands correctly on the next field. eir_len does not, and the shortfall compounds across fields until eir_get_data() reads the length and type bytes of a "field" past the end of the buffer. For an ISO broadcast sink that buffer is hcon->le_per_adv_data[], filled from the periodic advertising reports of a remote broadcaster. A PA payload packed with mismatching Service Data fields walks off the array into the rest of struct hci_conn. A drifted field that matches the BAA UUID puts those bytes in iso_pi(sk)->base, where user space reads them back with getsockopt(BT_ISO_BASE). Recompute eir_len from the end of the buffer each iteration. Fixes: 8f9ae5b3ae80 ("Bluetooth: eir: Add helpers for managing service data") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/eir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/bluetooth/eir.c +++ b/net/bluetooth/eir.c @@ -369,6 +369,7 @@ u8 eir_create_scan_rsp(struct hci_dev *h void *eir_get_service_data(u8 *eir, size_t eir_len, u16 uuid, size_t *len) { + const u8 *eir_end = eir + eir_len; size_t dlen; while ((eir = eir_get_data(eir, eir_len, EIR_SERVICE_DATA, &dlen))) { @@ -381,7 +382,7 @@ void *eir_get_service_data(u8 *eir, size } eir += dlen; - eir_len -= dlen; + eir_len = eir_end - eir; } return NULL;