Skip to content

[PW_SID:1104768] [v2] Bluetooth: eir: Fix stack OOB write when prepending the Flags AD#275

Open
BluezTestBot wants to merge 1 commit into
workflowfrom
1104768
Open

[PW_SID:1104768] [v2] Bluetooth: eir: Fix stack OOB write when prepending the Flags AD#275
BluezTestBot wants to merge 1 commit into
workflowfrom
1104768

Conversation

@BluezTestBot
Copy link
Copy Markdown

eir_create_adv_data() builds the advertising data into a fixed-size
buffer ("size", 31 for the legacy path). It may prepend a 3-byte "Flags"
AD structure (LE_AD_NO_BREDR on an LE-only controller) and then copies
the per-instance data without checking that it still fits:

memcpy(ptr, adv->adv_data, adv->adv_data_len);

tlv_data_max_len() only reserves those 3 bytes when the user-supplied
flags carry a managed-flags bit, so an instance added with flags == 0 is
accepted with adv_data_len up to the full buffer. At advertise time the
flags are still prepended, and the memcpy() writes 3 + adv_data_len
bytes into the size-byte buffer:

BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301)
Write of size 31 at addr ffff88800a547bdc by task kworker/u9:0/65
Workqueue: hci0 hci_cmd_sync_work
__asan_memcpy (mm/kasan/shadow.c:106)
eir_create_adv_data (net/bluetooth/eir.c:301)
hci_update_adv_data_sync (net/bluetooth/hci_sync.c:1310)
hci_schedule_adv_instance_sync (net/bluetooth/hci_sync.c:1817)
hci_cmd_sync_work (net/bluetooth/hci_sync.c:332)
This frame has 1 object:
[32, 64) 'cp'

The "Flags" structure is added by the kernel, not requested by
userspace, so only prepend it when it fits together with the instance
advertising data; when there is no room for both, drop the flags rather
than the user-provided data.

Reachable by a local user with CAP_NET_ADMIN owning an LE-only
controller on the legacy advertising path.

Fixes: b44133f ("Bluetooth: Support the "discoverable" adv flag")
Reported-by: Xiang Mei xmei5@asu.edu
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Weiming Shi bestswngs@gmail.com

v2: drop the kernel-added "Flags" AD when it does not fit with the instance data,
instead of dropping the user data .

net/bluetooth/eir.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

eir_create_adv_data() builds the advertising data into a fixed-size
buffer ("size", 31 for the legacy path). It may prepend a 3-byte "Flags"
AD structure (LE_AD_NO_BREDR on an LE-only controller) and then copies
the per-instance data without checking that it still fits:

	memcpy(ptr, adv->adv_data, adv->adv_data_len);

tlv_data_max_len() only reserves those 3 bytes when the user-supplied
flags carry a managed-flags bit, so an instance added with flags == 0 is
accepted with adv_data_len up to the full buffer. At advertise time the
flags are still prepended, and the memcpy() writes 3 + adv_data_len
bytes into the size-byte buffer:

  BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301)
  Write of size 31 at addr ffff88800a547bdc by task kworker/u9:0/65
  Workqueue: hci0 hci_cmd_sync_work
   __asan_memcpy (mm/kasan/shadow.c:106)
   eir_create_adv_data (net/bluetooth/eir.c:301)
   hci_update_adv_data_sync (net/bluetooth/hci_sync.c:1310)
   hci_schedule_adv_instance_sync (net/bluetooth/hci_sync.c:1817)
   hci_cmd_sync_work (net/bluetooth/hci_sync.c:332)
  This frame has 1 object:
   [32, 64) 'cp'

The "Flags" structure is added by the kernel, not requested by
userspace, so only prepend it when it fits together with the instance
advertising data; when there is no room for both, drop the flags rather
than the user-provided data.

Reachable by a local user with CAP_NET_ADMIN owning an LE-only
controller on the legacy advertising path.

Fixes: b44133f ("Bluetooth: Support the "discoverable" adv flag")
Reported-by: Xiang Mei <xmei5@asu.edu>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

CheckPatch
Desc: Run checkpatch.pl script
Duration: 0.69 seconds
Result: FAIL
Output:

[v2] Bluetooth: eir: Fix stack OOB write when prepending the Flags AD
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#136: 
Reported-by: Xiang Mei <xmei5@asu.edu>
Assisted-by: Claude:claude-opus-4-8

total: 0 errors, 1 warnings, 0 checks, 15 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14607518.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

VerifyFixes
Desc: Verify Fixes tag format and validity
Duration: 0.11 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

VerifySignedoff
Desc: Verify Signed-off-by chain
Duration: 0.11 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

GitLint
Desc: Run gitlint
Duration: 0.28 seconds
Result: FAIL
Output:

[v2] Bluetooth: eir: Fix stack OOB write when prepending the Flags AD

8: B3 Line contains hard tab characters (\t): "	memcpy(ptr, adv->adv_data, adv->adv_data_len);"
16: B1 Line exceeds max length (82>80): "  BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301)"
39: B1 Line exceeds max length (81>80): "v2: drop the kernel-added "Flags" AD when it does not fit with the instance data,"

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

SubjectPrefix
Desc: Check subject contains "Bluetooth" prefix
Duration: 0.11 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

BuildKernel
Desc: Build Kernel for Bluetooth
Duration: 24.67 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

CheckAllWarning
Desc: Run linux kernel with all warning enabled
Duration: 27.02 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

CheckSparse
Desc: Run sparse tool with linux kernel
Duration: 26.04 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

BuildKernel32
Desc: Build 32bit Kernel for Bluetooth
Duration: 24.01 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunnerSetup
Desc: Setup kernel and bluez for test-runner
Duration: 529.67 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_l2cap-tester
Desc: Run l2cap-tester with test-runner
Duration: 60.82 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_iso-tester
Desc: Run iso-tester with test-runner
Duration: 80.07 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_bnep-tester
Desc: Run bnep-tester with test-runner
Duration: 18.82 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_mgmt-tester
Desc: Run mgmt-tester with test-runner
Duration: 215.41 seconds
Result: FAIL
Output:

Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.247 seconds

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_rfcomm-tester
Desc: Run rfcomm-tester with test-runner
Duration: 25.46 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_sco-tester
Desc: Run sco-tester with test-runner
Duration: 32.57 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_ioctl-tester
Desc: Run ioctl-tester with test-runner
Duration: 26.03 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_mesh-tester
Desc: Run mesh-tester with test-runner
Duration: 25.87 seconds
Result: FAIL
Output:

Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    2.452 seconds
Mesh - Send cancel - 2                               Timed out    1.990 seconds

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_smp-tester
Desc: Run smp-tester with test-runner
Duration: 27.08 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_userchan-tester
Desc: Run userchan-tester with test-runner
Duration: 19.66 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestRunner_6lowpan-tester
Desc: Run 6lowpan-tester with test-runner
Duration: 22.53 seconds
Result: PASS

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 23.19 seconds
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants