[PW_SID:1080259] Bluetooth: RFCOMM: validate skb length in MCC handlers#70
[PW_SID:1080259] Bluetooth: RFCOMM: validate skb length in MCC handlers#70BluezTestBot wants to merge 1 commit intoworkflowfrom
Conversation
rfcomm_recv_pn(), rfcomm_recv_rpn(), rfcomm_recv_rls(), and rfcomm_recv_msc() cast skb->data to their respective structs without first checking skb->len. A remote device can send a short MCC frame, causing out-of-bounds reads from the skb buffer. For rfcomm_recv_pn(), the uninitialized pn->mtu value is stored in d->mtu via rfcomm_apply_pn(), then echoed back to the remote device in the PN response, leaking kernel heap data. This results in use of uninitialized memory, as reported by KMSAN. Add explicit skb->len checks against the expected structure size at the start of each handler before accessing the payload. ===================================================== BUG: KMSAN: uninit-value in rfcomm_run+0x7eae/0xee90 rfcomm_run+0x7eae/0xee90 kthread+0x53f/0x600 ret_from_fork+0x20f/0x910 ret_from_fork_asm+0x1a/0x30 Uninit was created at: kmem_cache_alloc_node_noprof+0x3cd/0x12d0 __alloc_skb+0x855/0x1190 vhci_write+0x125/0x960 vfs_write+0xbe1/0x15c0 ksys_write+0x1d9/0x470 __x64_sys_write+0x97/0xf0 x64_sys_call+0x2ff0/0x3ea0 do_syscall_64+0x134/0xf80 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 0 UID: 0 PID: 3374 Comm: krfcommd Tainted: G W 7.0.0-rc7 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Kernel panic - not syncing: kmsan.panic set ... ===================================================== Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: SeungJu Cheon <suunj1331@gmail.com>
|
CheckPatch |
|
GitLint |
|
SubjectPrefix |
|
BuildKernel |
|
CheckAllWarning |
|
CheckSparse |
|
BuildKernel32 |
|
TestRunnerSetup |
|
TestRunner_l2cap-tester |
|
TestRunner_iso-tester |
|
TestRunner_bnep-tester |
|
TestRunner_mgmt-tester |
|
TestRunner_rfcomm-tester |
|
TestRunner_sco-tester |
|
TestRunner_ioctl-tester |
|
TestRunner_mesh-tester |
|
TestRunner_smp-tester |
|
TestRunner_userchan-tester |
|
TestRunner_6lowpan-tester |
|
IncrementalBuild |
rfcomm_recv_pn(), rfcomm_recv_rpn(), rfcomm_recv_rls(), and
rfcomm_recv_msc() cast skb->data to their respective structs
without first checking skb->len. A remote device can send a
short MCC frame, causing out-of-bounds reads from the skb buffer.
For rfcomm_recv_pn(), the uninitialized pn->mtu value is stored
in d->mtu via rfcomm_apply_pn(), then echoed back to the remote
device in the PN response, leaking kernel heap data.
This results in use of uninitialized memory, as reported by KMSAN.
Add explicit skb->len checks against the expected structure size
at the start of each handler before accessing the payload.
=====================================================
BUG: KMSAN: uninit-value in rfcomm_run+0x7eae/0xee90
rfcomm_run+0x7eae/0xee90
kthread+0x53f/0x600
ret_from_fork+0x20f/0x910
ret_from_fork_asm+0x1a/0x30
Uninit was created at:
kmem_cache_alloc_node_noprof+0x3cd/0x12d0
__alloc_skb+0x855/0x1190
vhci_write+0x125/0x960
vfs_write+0xbe1/0x15c0
ksys_write+0x1d9/0x470
__x64_sys_write+0x97/0xf0
x64_sys_call+0x2ff0/0x3ea0
do_syscall_64+0x134/0xf80
entry_SYSCALL_64_after_hwframe+0x77/0x7f
CPU: 0 UID: 0 PID: 3374 Comm: krfcommd Tainted: G W 7.0.0-rc7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
Kernel panic - not syncing: kmsan.panic set ...
Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: SeungJu Cheon suunj1331@gmail.com
net/bluetooth/rfcomm/core.c | 40 +++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)