From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 623B43ACA75 for ; Tue, 7 Jul 2026 22:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783461941; cv=none; b=h3Lu4p39MPGOuY9Sg1VcuCDgIqqCBYFZ18/QS5DZwm9/XDfnunR1K34W4x2+gxB9jIBvKkEFn3Pn+fi8n83ai2c7wkayTEYXiv47LozXnzy6IizHjiZpxQMTSu13VtUlf4FWVtX8zw/yDnpOMjpVYmWcdIDbPQjLHLUZN3OlBgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783461941; c=relaxed/simple; bh=pBjlrX7yc7iWSMsIP+cQ2j6MxLyzrTuCrJliZbSWiho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G438/9fbqwma290pONUgBQqTiljXBEpPmbzovEiQJjmCzkrI0GWRiTzZe5RdXHoHz3ScjRhKiUILyyjKMM7wwlvnSgALsf5ZbU9il4E6uz2F8Foj2AVd7VE1zvc93AsjNun5qeHakKhwW5y72uXOs6hsoIvXSNDzORvYnxYzj9E= 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=Kp0+p056; arc=none smtp.client-ip=209.85.222.172 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="Kp0+p056" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-92e99ef0902so200976585a.2 for ; Tue, 07 Jul 2026 15:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783461936; x=1784066736; 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:content-type; bh=MuDSN5qpWrmOuyqcOwJR50zBGcAs40Wq+fAb7qOT/cs=; b=Kp0+p056FNVnKZS4h9n44Fcw0+IIhJnXL+c4Bz8Rmjt15qmCSNKLAtP6tmjBma9VIu 5W/odDmPmudEEz1rIANtVYk2Zfq0ZzwjybIMhTN5S6Cd2Jm5dgOGPjeZSjHS51c4k+mV Z6IWdzuB1V7FXV67wKFbwU/+HMk3KdjN6ygm1+p+QZNHttMfQ4+3I+W3fYxGgYy+Ei0B gUyEFjhfRp1A+OIbXRgFhB11RLdQw7J9hMHDNtCMypGALfR0sir7oqKNJHVd5s6kd3kE KwUpZvy6Xnv1I2WC5WJ/B0m+0SfD5qdoimymhkOvi92p+8T/r7jgcEzT+/vZYC4RwoCD P6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783461936; x=1784066736; 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:content-type; bh=MuDSN5qpWrmOuyqcOwJR50zBGcAs40Wq+fAb7qOT/cs=; b=G602mLb7Gpci19BoHiqghW9iIvZs5kLBRogD8P4HFpd1+UPI7iB0KTlRSLwbJiyCDF 994EZpdsjxNGfuwdiYzIa7pcjCYl0WpyN8q4TOygeJon0sWhdCqZERjVhrR/NTTfopNI G9/9qezkToSEfs5IMRqjKjDui/3W9mm461odc9mtDhUIonvW1RGkqK784MzGCUT5K98F L0ULBCv+yU13h/mz++CjLd/pUkB5VwZTfyNf4LPbkEax7mIvcyh7I3M76br2qRxcZ/yL YsbQTK2fMTf1ViwzJfi667R2ZjQn/jTSIe3HATZrHHg/IsopaWJTnGz2tHJFUc+pP+2G 3llg== X-Forwarded-Encrypted: i=1; AHgh+RoRYN4qVprjx8Q8A5erkDEGz4MNsY5kQyN6hPwDf7xUVySYBVR7ug8mPs9tMjrcugvhmN6gm115yDZv5tA=@vger.kernel.org X-Gm-Message-State: AOJu0YzDMgYudxy7fqqNrg+s5sJkwUFcT6RivhXzTXHyhX9w5IMNsVEM JRWwNBYq8rkm57srpXt3slKVcNi4rck11ZVJOnhihG2+VpWxXDaGYIzL X-Gm-Gg: AfdE7clNHODOheAeuctc2KbHyJ219oSzeAKbDJQBYVVS7ggxGAw3DJSBLkj3TmSmr66 7pWTjjppAvcGGgvcWSwmjzTgBFHf4jU0tV672OcttFBN+esGkHmILxv5qOwi2RKcFY6qkoG8kVL rv6Sg9AlMLpNfgda2ELsTpsATGlvp0pkwjj+C5EdmyUOU+clXNedVB6Sa8RMFpH8mUCzQSXtzah xXflLta+3Erl64o0YxaguduHbhYjOqaga6x0EEQrWpmjYhyj3dEIafSIGXz3Lhzh72whjGIhqln ad34hjZZt1MDQ9/mfR6eAep9dce0A/B+6Sj+hi65bM89lkJ/AiAXIAAzjG9EjPRPWKbo2pVJ4Eo Oe8mzKNVPf6rwr/0E4e+CC/LPGu9NsuYPh7OIcdjCSupyobovNSIc22paTO/2WOriRCGdvljJ3+ Ah61QvNoGSswQfOXouk+8Ct0TE9keaOCQrTNQBBb0sD9jDVTPpewkR+kzcCFKfmQZADtGss17hU 2tIYqnL1/JEPjD2PL8G00sq9RqD7+1IGqGB X-Received: by 2002:a05:620a:4009:b0:915:a6ca:f12a with SMTP id af79cd13be357-92ebb58fed2mr863565585a.54.1783461935481; Tue, 07 Jul 2026 15:05:35 -0700 (PDT) Received: from jeremy.kali (srv1619992.hstgr.cloud. [2a02:4780:75:55a3::1]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92e90cc18f1sm1250745685a.40.2026.07.07.15.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 15:05:34 -0700 (PDT) From: "Jeremy Erazo (Devel Group)" To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , Sasha Levin , Luiz Augusto von Dentz , Marcel Holtmann , Johan Hedberg , Claudia Draghicescu , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2 6.6.y] Bluetooth: ISO: Copy BASE if service data matches EIR_BAA_SERVICE_UUID Date: Tue, 7 Jul 2026 22:05:25 +0000 Message-ID: <20260707220526.271712-2-mendozayt13@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260707220526.271712-1-mendozayt13@gmail.com> References: <20260702144207.320421-1-mendozayt13@gmail.com> <20260707220526.271712-1-mendozayt13@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: 8bit From: Jeremy Erazo commit f4da3ee15de9944482382181329bb6d7335ca003 upstream. Copy the content of a Periodic Advertisement Report to BASE only if the service UUID is Basic Audio Announcement Service UUID. [Stable backport rationale] This fix landed in mainline v6.7 without a Fixes: tag, so the stable autoselect bot never picked it up. linux-6.6.y HEAD (v6.6.143) still carries the pre-fix code at net/bluetooth/iso.c:1935: if (sk) { memcpy(iso_pi(sk)->base, ev3->data, ev3->length); iso_pi(sk)->base_len = ev3->length; } ev3->length is __u8 and iso_pi(sk)->base is __u8[BASE_MAX_LENGTH] where BASE_MAX_LENGTH is HCI_MAX_PER_AD_LENGTH(252) - EIR_SERVICE_DATA_LENGTH(4) = 248. When an attacker within BLE radio range sends an HCI_EV_LE_PER_ADV_REPORT with ev3->length in [249, 255], the memcpy writes 1 to 7 bytes past the buffer into the trailing fields of struct iso_pinfo, including the low bytes of the iso_pi(sk)->conn pointer. FORTIFY_SOURCE flags the write with "memcpy: detected field-spanning write" but does not block it. The upstream refactor addresses this by: 1. Filtering via eir_get_service_data() so only the BASE portion of the PA payload is copied. 2. Bounding the copy with base_len <= sizeof(iso_pi(sk)->base). Backport notes for 6.6.y: * eir_get_service_data() is already declared in net/bluetooth/eir.h. * The header include for eir.h and the EIR_BAA_SERVICE_UUID define are added here, matching the upstream commit. * The put_user() addition in iso_sock_getsockopt() that was part of the same upstream commit is not included; that hunk is a separate getsockopt correctness fix and is not required for the OOB write fix (getsockopt(BT_ISO_BASE) is a controlled path that already validates optlen against sizeof(iso_pi(sk)->base)). Applying the getsockopt hunk here would risk a user-visible ABI change on a stable branch. Reachability: any host with an ISO listening socket bound as a broadcast sink (LE Audio / Auracast). No pairing required. Fixes: 9c0826310bfb ("Bluetooth: ISO: Add support for periodic adv reports processing") Cc: stable@vger.kernel.org # 6.6.y Signed-off-by: Claudia Draghicescu Signed-off-by: Luiz Augusto von Dentz [jerazo: backport to 6.6.y; add #include "eir.h" and EIR_BAA_SERVICE_UUID define; drop unrelated getsockopt hunk] Signed-off-by: Jeremy Erazo --- net/bluetooth/iso.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 011b2187b..3259c9c1e 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -15,6 +15,8 @@ #include #include +#include "eir.h" + static const struct proto_ops iso_sock_ops; static struct bt_sock_list iso_sk_list = { @@ -47,6 +49,7 @@ static void iso_sock_kill(struct sock *sk); #define EIR_SERVICE_DATA_LENGTH 4 #define BASE_MAX_LENGTH (HCI_MAX_PER_AD_LENGTH - EIR_SERVICE_DATA_LENGTH) +#define EIR_BAA_SERVICE_UUID 0x1851 /* iso_pinfo flags values */ enum { @@ -1928,12 +1931,16 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) ev3 = hci_recv_event_data(hdev, HCI_EV_LE_PER_ADV_REPORT); if (ev3) { + size_t base_len = ev3->length; + u8 *base; + sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr, iso_match_sync_handle_pa_report, ev3); - - if (sk) { - memcpy(iso_pi(sk)->base, ev3->data, ev3->length); - iso_pi(sk)->base_len = ev3->length; + base = eir_get_service_data(ev3->data, ev3->length, + EIR_BAA_SERVICE_UUID, &base_len); + if (base && sk && base_len <= sizeof(iso_pi(sk)->base)) { + memcpy(iso_pi(sk)->base, base, base_len); + iso_pi(sk)->base_len = base_len; } } else { sk = iso_get_sock_listen(&hdev->bdaddr, BDADDR_ANY, NULL, NULL); -- 2.53.0