From nobody Mon Sep 28 23:55:40 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 031B83750AC for ; Sat, 15 Aug 2026 06:24:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786775067; cv=none; b=KE9JEnFEQ3m7TIHVvxu5cxxACp4j9VBFh1zg3Uqw5ylfXJIfEqPCDdJl84zRj7ZzjOMqdViq3GWgAO79yqk/K8xe2PQChI+zuLmlC0OYEZSSY1gFLFx5EK3lMF2+sb6rvrEeWDkqc2uGKp3tAzdaylod8fBCGZdwNELTHNwWK+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786775067; c=relaxed/simple; bh=JEvtiCiT2SNAxC5dJCpMsln8bLpWOAJsYTD5ozGyV1A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uKu9z/X3lXkLW5GlWBtn18NRl2NOkeKARnSnytROtzYquBnSgUC+NnQdsDNQG06S+hwcIGdecUjwgBKNBmKgVzt4TgErZndBnmAGsEgsdC+Y+Gfc11gGM8+AW+EG+rS5nTmXfkvaOQUfQ3PC7zOGqeEAGtXWTT48z6b60njzwKE= 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=gMkdlAid; arc=none smtp.client-ip=209.85.216.48 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="gMkdlAid" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-38dfe910e9dso1877710a91.3 for ; Fri, 14 Aug 2026 23:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786775064; x=1787379864; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=WQWoK3r7vnsX7xRRasz6aMzEcL/clDDXaeOmGh8lZnw=; b=gMkdlAidrAROE6Mt6bJ66128vD4Ed+a3elEJmGw8aKt2UnrYnnQVkvWjjMjQZE+vXy +D1xC38pXUcpxva4C+WLA6X5YZEpYZURpD7/QZEupq0mgF0tG3tblSrT39Q14InpJnwG J4YCLpzPf8nuk60CPGoTZq361SzHT2s5jdU4HeUjllc5lLh1B1LXKYOw7Z+MgX5Ol3IO k72g7FvmcAK9K2AZNpI0lWESKS5Su/CoA3luOOzEiDADSDT/Fipmft/NqS/JSsyFB7wn AswcAbMYHSdJdwk1VPBDEDx6CUevwMnlnFyF2NWsbeh/KcZYwU7HRGITxN0lnPj/AiPM 0eXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786775064; x=1787379864; h=content-transfer-encoding:mime-version: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=WQWoK3r7vnsX7xRRasz6aMzEcL/clDDXaeOmGh8lZnw=; b=WcLz4LdreFLxxoENO3yokDRYs0hLco2EljCvvaWxcmxJi5CklBZtqYWSb/lJ3gWdih +w/cQifYdRMxmgRvlPu39wXndoqixw8oKpc9imGDiAj/ro/g41mBWSZrYMnzRtvBjmDE Km5ilV0pSC4CpcRzDCKW49KK8TumGu5ugZ9RMONQOFr/bUP/bUgErCT6irTRCTTzP+RF YqB5M9U1GROH3kfgLsoLX95qBK1d2O2PDsG6icEtSvF4en/wJdsiyvgSkkFGDKAQb9KX qZXAHzYlo1yesi71air7TPAboKUKB/33uWljZPQMF3AhdgDudSmJ1E/caGCj1zpjDKe5 ALhA== X-Forwarded-Encrypted: i=1; AHgh+RrBIWelR476m79cM92fQwPqH4ASD8eX8ZaYhyNvfDcNFe1cfejIeSLf8AmIl51IJBZA2AFGnB+9XAJEnHU=@vger.kernel.org X-Gm-Message-State: AOJu0YytxlJaWq8kmlSqk50cS90BToDu5MGJiOFMuprogwl+S4xcRhXS L0w1AoXA52aaPlJ58NG9vSjnZKIm1ylhcDp9oaGZ5kSLiW5XcM1zvIIQ X-Gm-Gg: AR+sD11AghxIokIkxiqHthdY+qGB2zfSdh8hXoW8b10t1OqJq1nYIwdyP+fMPHJWB0K FSPmve8RhI8h7moPcQe0xob3nHB7PlPRD1Zi5X4uNh3BrvwS84nZ0Esj8dqQNYP+LeuwdsABID0 +/v3nT6qW8tbsq/KhEvaZ6ejrvGPc+XKhgNcvyEyrHPSGiTfBSOJGvlNiAtNmoR0QKpEoFgFG11 b81N+Mq5CmLN6L6wdlSOLqba3UR6CKs6SO9wZTIXSheNQa8iA+HDSQFzlI/NEin3x8ExtEV5+/u Uwza6tkmpzAVVlGUtqFj2ZZGe6CYoNSljgCR7ONiM1pTOtXLqYqNLoXfr5NaGH+LMNqyGbFLaK6 BER4Ol8x1FCbUv7MTqHZ1Wu2cgbLw74vWP9QN9+xDt02HFATXQAK2u90e15jSVBbC+OMTzwia6a 8PTpivHuuc7b4a1Phdy8yXtL8iX57wJp2slzP9Oy6IatnqafafuKuC2VWtlROgEnCh7eOZGMaDy CL9QDyQMOmpizCwPC57hwvhwa2TK1yp6/N1gBMuLRYoz8Wag9gfSA== X-Received: by 2002:a17:90b:1806:b0:38d:ec31:4840 with SMTP id 98e67ed59e1d1-3933b907356mr11091295a91.13.1786775064186; Fri, 14 Aug 2026 23:24:24 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-394ea96c7fcsm5427946a91.3.2026.08.14.23.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 23:24:23 -0700 (PDT) From: HyeongJun An To: Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, HyeongJun An Subject: [PATCH v3] Bluetooth: eir: Fix OOB read in eir_get_service_data() Date: Sat, 15 Aug 2026 15:24:19 +0900 Message-ID: <20260815062419.37489-1-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.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" eir_get_service_data() walks the advertising data for a Service Data field with a matching UUID. On a mismatch it advances: eir +=3D dlen; eir_len -=3D 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 --- Changes in v3: - Commit message only, shortened. No code change from v2. v2: https://lore.kernel.org/all/20260624143222.883120-1-sammiee5311@gmail.c= om/ v2 drew no comments. Its bot run was 20/22 PASS. The mgmt-tester and mesh-tester failures are not from this patch -- eir_get_service_data() has no callers in mesh or mgmt code, only in hci_sync.c and iso.c, and iso-tester, which does cover the path, passed. The previous fix to this function, 20a2aa01f5ae ("Bluetooth: Fix NULL pointer deference on eir_get_service_data"), also failed mgmt-tester on its bot run and was merged. net/bluetooth/eir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/eir.c b/net/bluetooth/eir.c index 1de5f9df6eec..a55696820b22 100644 --- a/net/bluetooth/eir.c +++ b/net/bluetooth/eir.c @@ -369,6 +369,7 @@ u8 eir_create_scan_rsp(struct hci_dev *hdev, u8 instanc= e, u8 *ptr) =20 void *eir_get_service_data(u8 *eir, size_t eir_len, u16 uuid, size_t *len) { + const u8 *eir_end =3D eir + eir_len; size_t dlen; =20 while ((eir =3D eir_get_data(eir, eir_len, EIR_SERVICE_DATA, &dlen))) { @@ -381,7 +382,7 @@ void *eir_get_service_data(u8 *eir, size_t eir_len, u16= uuid, size_t *len) } =20 eir +=3D dlen; - eir_len -=3D dlen; + eir_len =3D eir_end - eir; } =20 return NULL; --=20 2.43.0