[ 1776.466411][T12145] BUG: KASAN: slab-out-of-bounds in usbpd_mi_vdm_received_cb+0x478/0xb84 [usbpd] [ 1776.466641][T12145] Read of size 4 at addr ffffff808d6c0a60 by task kworker/u17:3/12145 [ 1776.466686][T12145] CPU: 7 PID: 12145 Comm: kworker/u17:3 Tainted: G C OE 6.1.99-android14-11-maybe-dirty-qki-consolidate #1 [ 1776.466716][T12145] Hardware name: Qualcomm Technologies, Inc. Spring QRD (DT) [ 1776.466736][T12145] Workqueue: usbpd_wq usbpd_sm [usbpd] [ 1776.466946][T12145] Call trace: [ 1776.466962][T12145] dump_backtrace+0x1c0/0x1f0 [ 1776.466992][T12145] show_stack+0x2c/0x3c [ 1776.467017][T12145] dump_stack_lvl+0x104/0x170 [ 1776.467045][T12145] print_report+0x15c/0x4a0 [ 1776.467080][T12145] kasan_report+0xd4/0x130 [ 1776.467109][T12145] __asan_load4+0x94/0x9c [ 1776.467143][T12145] usbpd_mi_vdm_received_cb+0x478/0xb84 [usbpd] [ 1776.467346][T12145] handle_vdm_rx+0x360/0x14f0 [usbpd] [ 1776.467548][T12145] handle_state_snk_ready+0x3f0/0x10dc [usbpd] [ 1776.467748][T12145] usbpd_sm+0x6b4/0x12dc [usbpd] [ 1776.467950][T12145] process_one_work+0x538/0xbbc [ 1776.467982][T12145] worker_thread+0x57c/0x95c [ 1776.468012][T12145] kthread+0x1c4/0x1f8 [ 1776.468042][T12145] ret_from_fork+0x10/0x20 [ 1776.468084][T12145] Allocated by task 18133: [ 1776.468103][T12145] kasan_set_track+0x4c/0x84 [ 1776.468126][T12145] kasan_save_alloc_info+0x24/0x34 [ 1776.468148][T12145] __kasan_kmalloc+0xa0/0xbc [ 1776.468168][T12145] __kmalloc+0xf8/0x284 [ 1776.468187][T12145] phy_msg_received+0x51c/0xefc [usbpd] [ 1776.468382][T12145] pdphy_msg_rx_irq+0x318/0x4f8 [qpnp_pdphy] [ 1776.468436][T12145] __handle_irq_event_percpu+0x16c/0x554 [ 1776.468455][T12145] handle_irq_event+0x6c/0x12c [ 1776.468471][T12145] handle_edge_irq+0x1ec/0x68c [ 1776.468493][T12145] generic_handle_irq+0x70/0x94 [ 1776.468509][T12145] periph_interrupt+0x24c/0x2c4 [spmi_pmic_arb] [ 1776.468581][T12145] pmic_arb_chained_irq+0x2f4/0x5e4 [spmi_pmic_arb] [ 1776.468650][T12145] generic_handle_domain_irq+0x74/0x98 [ 1776.468667][T12145] gic_handle_irq+0x70/0x1bc [ 1776.468699][T12145] The buggy address belongs to the object at ffffff808d6c0a40 [ 1776.468699][T12145] which belongs to the cache kmalloc-64 of size 64 [ 1776.468723][T12145] The buggy address is located 32 bytes inside of [ 1776.468723][T12145] 64-byte region [ffffff808d6c0a40, ffffff808d6c0a80) [ 1776.468763][T12145] The buggy address belongs to the physical page: [ 1776.468781][T12145] page:fffffffe0235b000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10d6c0 [ 1776.468801][T12145] head:fffffffe0235b000 order:1 compound_mapcount:0 compound_pincount:0 [ 1776.468815][T12145] flags: 0x4000000000010200(slab|head|zone=1) [ 1776.468839][T12145] raw: 4000000000010200 fffffffe07f37d08 ffffff800b41c3f0 ffffff800b4283c0 [ 1776.468856][T12145] raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000 [ 1776.468866][T12145] page dumped because: kasan: bad access detected [ 1776.468876][T12145] page_owner tracks the page as allocated [ 1776.468892][T12145] page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 950, tgid 950 (modprobe), ts 158955933088, free_ts 158788154806 [ 1776.468932][T12145] post_alloc_hook+0x110/0x118 [ 1776.468956][T12145] prep_new_page+0x34/0x244 [ 1776.468982][T12145] get_page_from_freelist+0x1938/0x19a0 [ 1776.469006][T12145] __alloc_pages+0x144/0x35c [ 1776.469028][T12145] alloc_slab_page+0x8c/0x1ac [ 1776.469050][T12145] new_slab+0xa4/0x374 [ 1776.469070][T12145] ___slab_alloc+0x844/0xd08 [ 1776.469087][T12145] __slab_alloc+0x6c/0xac [ 1776.469105][T12145] __kmem_cache_alloc_node+0x26c/0x2e0 [ 1776.469123][T12145] __kmalloc_node_track_caller+0xe0/0x26c [ 1776.469143][T12145] kvasprintf+0xbc/0x16c [ 1776.469165][T12145] kasprintf+0x80/0xb0 [ 1776.469184][T12145] iommu_group_add_device+0xd0/0x468 [ 1776.469207][T12145] __iommu_probe_device+0x328/0x558 [ 1776.469234][T12145] iommu_probe_device+0x44/0x380 [ 1776.469257][T12145] of_iommu_configure+0x308/0x3b8 [ 1776.469277][T12145] page last free stack trace: [ 1776.469293][T12145] free_unref_page_prepare+0x520/0x550 [ 1776.469315][T12145] free_unref_page+0x7c/0x408 [ 1776.469336][T12145] __free_pages+0xf4/0x120 [ 1776.469356][T12145] __vunmap+0x51c/0x5fc [ 1776.469375][T12145] vfree+0xa4/0xf4 [ 1776.469393][T12145] load_module+0x2d78/0x3040 [ 1776.469416][T12145] __arm64_sys_finit_module+0x170/0x1d4 [ 1776.469436][T12145] invoke_syscall+0x88/0x1d4 [ 1776.469458][T12145] el0_svc_common+0xec/0x1cc [ 1776.469479][T12145] do_el0_svc+0x50/0x194 [ 1776.469500][T12145] el0_svc+0x30/0x84 [ 1776.469518][T12145] el0t_64_sync_handler+0x68/0xb4 [ 1776.469535][T12145] el0t_64_sync+0x190/0x194 [ 1776.469565][T12145] Memory state around the buggy address: [ 1776.469584][T12145] ffffff808d6c0900: fc fc fc fc fc fc fc fc 00 00 00 00 03 fc fc fc [ 1776.469605][T12145] ffffff808d6c0980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 1776.469626][T12145] >ffffff808d6c0a00: fc fc fc fc fc fc fc fc 00 00 00 00 fc fc fc fc [ 1776.469645][T12145] ^ [ 1776.469664][T12145] ffffff808d6c0a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 1776.469685][T12145] ffffff808d6c0b00: fc fc fc fc fc fc fc fc 00 00 00 00 03 fc fc fc [ 1776.469704][T12145] ==================================================================
得到的信息点:
问题类型:slab-out-of-bounds
问题函数:usbpd_mi_vdm_received_cb+0x478/0xb84 [usbpd]
越界地址:Read of size 4 at addr ffffff808d6c0a60 by task kworker/u17:3/12145
2.2 trace32恢复现场
对应的源码
目前来看死在了第5395行的case中,而这个case只有一个for循环
1 2 3 4 5 6
case USBPD_UVDM_SESSION_SEED: for (i = 0; i < USBPD_UVDM_SS_LEN; i++) { pd->vdm_data.s_secert[i] = vdos[i]; usbpd_dbg(&pd->dev, "usbpd s_secert vdos[%d]=0x%x", i, vdos[i]); } break;
switch (PD_MSG_HDR_TYPE(rx_msg->hdr)) { case MSG_SOURCE_CAPABILITIES: /* save the PDOs so userspace can further evaluate */ memset(&pd->received_pdos, 0, sizeof(pd->received_pdos)); memcpy(&pd->received_pdos, rx_msg->payload, min_t(size_t, rx_msg->data_len, sizeof(pd->received_pdos))); pd->src_cap_id++;
usbpd_set_state(pd, PE_SNK_EVALUATE_CAPABILITY); break; case MSG_VDM: handle_vdm_rx(pd, rx_msg); //这边传入 break;
handle_data_snk_ready的调用栈
1 2 3 4 5 6 7 8 9 10 11
staticvoidhandle_state_snk_ready(struct usbpd *pd, struct rx_msg *rx_msg) { int ret;
/** * list_first_entry - get the first element from a list * @ptr: the list head to take the element from. * @type: the type of the struct this is embedded in. * @member: the name of the list_head within the struct. * * Note, that list is expected to be not empty. */ #define list_first_entry(ptr, type, member) \ list_entry((ptr)->next, type, member)
/* check header's count field to see if it matches len */ if (PD_MSG_HDR_COUNT(header) != (len / 4)) { usbpd_err(&pd->dev, "header count (%d) mismatch, len=%zd\n", PD_MSG_HDR_COUNT(header), len); return; }
/* if spec rev differs (i.e. is older), update PHY */ if (PD_MSG_HDR_REV(header) < pd->spec_rev) pd->spec_rev = PD_MSG_HDR_REV(header);