* [PATCH] Bluetooth: eir: validate service data length before reading UUID
@ 2026-09-06 23:37 Aamir Ahmed
2026-09-07 0:50 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Aamir Ahmed @ 2026-09-06 23:37 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth, netdev, linux-kernel, stable
eir_get_service_data() reads a 16-bit UUID from the service data using
get_unaligned_le16() without first checking that the data is long enough
to hold a UUID16 (2 bytes). If a malformed EIR entry has a service data
field with only 1 byte of payload (field_len=2), eir_get_data() returns
dlen=1. The subsequent get_unaligned_le16() then reads 1 byte past the
field boundary.
Additionally, if the corrupted UUID happens to match, the length
calculation "dlen - 2" underflows to SIZE_MAX since dlen is size_t.
Current callers either pass NULL for the length parameter or bounds-check
the returned length, but future callers may not.
Add a check that dlen >= sizeof(u16) and skip fields that are too short
to contain a valid UUID16.
Fixes: 8f9ae5b3ae80 ("Bluetooth: eir: Add helpers for managing service data")
Cc: stable@vger.kernel.org
Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
---
net/bluetooth/eir.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/eir.c b/net/bluetooth/eir.c
index a55696820b22..ee0136bfae40 100644
--- a/net/bluetooth/eir.c
+++ b/net/bluetooth/eir.c
@@ -373,7 +373,15 @@ void *eir_get_service_data(u8 *eir, size_t eir_len, u16 uuid, size_t *len)
size_t dlen;
while ((eir = eir_get_data(eir, eir_len, EIR_SERVICE_DATA, &dlen))) {
- u16 value = get_unaligned_le16(eir);
+ u16 value;
+
+ if (dlen < sizeof(value)) {
+ eir += dlen;
+ eir_len = eir_end - eir;
+ continue;
+ }
+
+ value = get_unaligned_le16(eir);
if (uuid == value) {
if (len)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: Bluetooth: eir: validate service data length before reading UUID
2026-09-06 23:37 [PATCH] Bluetooth: eir: validate service data length before reading UUID Aamir Ahmed
@ 2026-09-07 0:50 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-07 0:50 UTC (permalink / raw)
To: linux-bluetooth, elb12345
[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1159232
---Test result---
Test Summary:
CheckPatch PASS 0.75 seconds
VerifyFixes PASS 0.13 seconds
VerifySignedoff PASS 0.13 seconds
GitLint PASS 0.33 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 28.78 seconds
CheckAllWarning PASS 31.12 seconds
CheckSparse PASS 29.39 seconds
BuildKernel32 PASS 27.05 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 511.96 seconds
TestRunner_l2cap-tester PASS 67.22 seconds
TestRunner_iso-tester PASS 109.86 seconds
TestRunner_bnep-tester PASS 20.20 seconds
TestRunner_mgmt-tester FAIL 228.04 seconds
TestRunner_rfcomm-tester PASS 27.18 seconds
TestRunner_sco-tester PASS 33.25 seconds
TestRunner_ioctl-tester PASS 27.93 seconds
TestRunner_mesh-tester FAIL 27.37 seconds
TestRunner_smp-tester PASS 24.28 seconds
TestRunner_userchan-tester PASS 21.10 seconds
TestRunner_6lowpan-tester PASS 24.05 seconds
IncrementalBuild PASS 26.07 seconds
Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 501, Passed: 495 (98.8%), Failed: 2, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.260 seconds
LL Privacy - Unpair 1 Timed out 1.876 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.588 seconds
Mesh - Send cancel - 2 Timed out 1.992 seconds
https://github.com/bluez/bluetooth-next/pull/713
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bluetooth: eir: validate service data length before reading UUID
2026-09-06 23:37 [PATCH] Bluetooth: eir: validate service data length before reading UUID Aamir Ahmed
2026-09-07 0:50 ` bluez.test.bot
@ 2026-09-08 16:30 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-08 16:30 UTC (permalink / raw)
To: Aamir Ahmed; +Cc: luiz.dentz, linux-bluetooth, netdev, linux-kernel, stable
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Mon, 7 Sep 2026 00:37:43 +0100 you wrote:
> eir_get_service_data() reads a 16-bit UUID from the service data using
> get_unaligned_le16() without first checking that the data is long enough
> to hold a UUID16 (2 bytes). If a malformed EIR entry has a service data
> field with only 1 byte of payload (field_len=2), eir_get_data() returns
> dlen=1. The subsequent get_unaligned_le16() then reads 1 byte past the
> field boundary.
>
> [...]
Here is the summary with links:
- Bluetooth: eir: validate service data length before reading UUID
https://git.kernel.org/bluetooth/bluetooth-next/c/334ddae615d8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-08 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 23:37 [PATCH] Bluetooth: eir: validate service data length before reading UUID Aamir Ahmed
2026-09-07 0:50 ` bluez.test.bot
2026-09-08 16:30 ` [PATCH] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox