[PW_SID:1092077] Bluetooth: mgmt: validate advertising TLV envelopes before parsing#159
[PW_SID:1092077] Bluetooth: mgmt: validate advertising TLV envelopes before parsing#159BluezTestBot wants to merge 6 commits into
Conversation
This patch adds workflow files for ci: [sync.yml] - The workflow file for scheduled work - Sync the repo with upstream repo and rebase the workflow branch - Review the patches in the patchwork and creates the PR if needed [ci.yml] - The workflow file for CI tasks - Run CI tests when PR is created Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
This replaces the bzcafe action with bluez/action-ci so we can maintain everything in the github bluez organization Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This attempts to sync every 5 minutes instead of 30. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
bluez/action-ci uses master as default branch for workflow which is incorrect for kernel Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The CI action now creates individual GitHub Check Runs per test, which requires 'checks: write' permission on the GITHUB_TOKEN. Also make the pull_request trigger types explicit to include 'reopened', allowing CI to be retriggered by closing and reopening a PR.
tlv_data_is_valid() loads the field length from data[i] and then inspects data[i + 1] for managed EIR types before it proves that the element still fits inside the supplied advertising buffer. Move the existing per-element length check ahead of the type-byte tests so every non-empty element is proven to fit before data[i + 1] is read. Also reject MGMT_OP_ADD_EXT_ADV_DATA commands whose declared advertising and scan-response lengths do not match the trailing command payload. Unlike MGMT_OP_ADD_ADVERTISING, that path did not validate the outer envelope before slicing cp->data for tlv_data_is_valid(). Sanitizer validation reported: BUG: KASAN: vmalloc-out-of-bounds in tlv_data_is_valid() Read of size 1 at addr ffffc9000031a000 Call trace: dump_stack_lvl() (?:?) print_address_description() (mm/kasan/report.c:373) tlv_data_is_valid() (net/bluetooth/mgmt.c:8623) print_report() (?:?) srso_alias_return_thunk() (arch/x86/include/asm/nospec-branch.h:375) kasan_addr_to_slab() (mm/kasan/common.c:45) kasan_report() (?:?) add_advertising() (net/bluetooth/mgmt.c:8751) __entry_text_end() (?:?) __hci_dev_get() (net/bluetooth/hci_core.c:67) do_raw_read_unlock() (kernel/locking/spinlock_debug.c:178) _raw_read_unlock() (kernel/locking/spinlock.c:262) hci_mgmt_cmd() (net/bluetooth/hci_sock.c:1619) hci_sock_sendmsg() (net/bluetooth/hci_sock.c:1800) sock_write_iter() (net/socket.c:1234) reacquire_held_locks() (kernel/locking/lockdep.c:5375) security_file_permission() (?:?) vfs_write() (fs/read_write.c:668) __sys_bind() (net/socket.c:1947) ksys_write() (fs/read_write.c:729) rcu_is_watching() (?:?) do_syscall_64() (arch/x86/entry/syscall_64.c:87) entry_SYSCALL_64_after_hwframe() (?:?) Signed-off-by: Zhang Cen <rollkingzzc@gmail.com>
|
CheckPatch |
|
GitLint |
|
SubjectPrefix |
|
BuildKernel |
|
CheckAllWarning |
|
CheckSparse |
|
BuildKernel32 |
|
TestRunnerSetup |
|
TestRunner_mgmt-tester |
|
TestRunner_mesh-tester |
|
IncrementalBuild |
5c3256e to
75a1a12
Compare
tlv_data_is_valid() loads the field length from data[i] and then inspects
data[i + 1] for managed EIR types before it proves that the element still
fits inside the supplied advertising buffer.
Move the existing per-element length check ahead of the type-byte tests so
every non-empty element is proven to fit before data[i + 1] is read.
Also reject MGMT_OP_ADD_EXT_ADV_DATA commands whose declared advertising
and scan-response lengths do not match the trailing command payload.
Unlike MGMT_OP_ADD_ADVERTISING, that path did not validate the outer
envelope before slicing cp->data for tlv_data_is_valid().
Sanitizer validation reported:
BUG: KASAN: vmalloc-out-of-bounds in tlv_data_is_valid()
Read of size 1 at addr ffffc9000031a000
Call trace:
dump_stack_lvl() (?:?)
print_address_description() (mm/kasan/report.c:373)
tlv_data_is_valid() (net/bluetooth/mgmt.c:8623)
print_report() (?:?)
srso_alias_return_thunk() (arch/x86/include/asm/nospec-branch.h:375)
kasan_addr_to_slab() (mm/kasan/common.c:45)
kasan_report() (?:?)
add_advertising() (net/bluetooth/mgmt.c:8751)
__entry_text_end() (?:?)
__hci_dev_get() (net/bluetooth/hci_core.c:67)
do_raw_read_unlock() (kernel/locking/spinlock_debug.c:178)
_raw_read_unlock() (kernel/locking/spinlock.c:262)
hci_mgmt_cmd() (net/bluetooth/hci_sock.c:1619)
hci_sock_sendmsg() (net/bluetooth/hci_sock.c:1800)
sock_write_iter() (net/socket.c:1234)
reacquire_held_locks() (kernel/locking/lockdep.c:5375)
security_file_permission() (?:?)
vfs_write() (fs/read_write.c:668)
__sys_bind() (net/socket.c:1947)
ksys_write() (fs/read_write.c:729)
rcu_is_watching() (?:?)
do_syscall_64() (arch/x86/entry/syscall_64.c:87)
entry_SYSCALL_64_after_hwframe() (?:?)
Signed-off-by: Zhang Cen rollkingzzc@gmail.com