• Guchun Chen's avatar
    drm/amdgpu: fix slab-out-of-bounds issue in amdgpu_vm_pt_create · 8ecee4cb
    Guchun Chen authored
    Recent code set xcp_id stored from file private data when opening
    device to amdgpu bo for accounting memory usage etc, but not all
    VMs are attached to this fpriv structure like the vm cases in
    amdgpu_mes_self_test, otherwise, KASAN will complain below out
    of bound access. And more importantly, VM code should not touch
    fpriv structure, so drop fpriv code handling from amdgpu_vm_pt.
    
    [   77.292314] BUG: KASAN: slab-out-of-bounds in amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
    [   77.293845] Read of size 4 at addr ffff888102c48a48 by task modprobe/1069
    [   77.294146] Call Trace:
    [   77.294178]  <TASK>
    [   77.294208]  dump_stack_lvl+0x49/0x63
    [   77.294260]  print_report+0x16f/0x4a6
    [   77.294307]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
    [   77.295979]  ? kasan_complete_mode_report_info+0x3c/0x200
    [   77.296057]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
    [   77.297556]  kasan_report+0xb4/0x130
    [   77.297609]  ? amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
    [   77.299202]  __asan_load4+0x6f/0x90
    [   77.299272]  amdgpu_vm_pt_create+0x17e/0x4b0 [amdgpu]
    [   77.300796]  ? amdgpu_init+0x6e/0x1000 [amdgpu]
    [   77.302222]  ? amdgpu_vm_pt_clear+0x750/0x750 [amdgpu]
    [   77.303721]  ? preempt_count_sub+0x18/0xc0
    [   77.303786]  amdgpu_vm_init+0x39e/0x870 [amdgpu]
    [   77.305186]  ? amdgpu_vm_wait_idle+0x90/0x90 [amdgpu]
    [   77.306683]  ? kasan_set_track+0x25/0x30
    [   77.306737]  ? kasan_save_alloc_info+0x1b/0x30
    [   77.306795]  ? __kasan_kmalloc+0x87/0xa0
    [   77.306852]  amdgpu_mes_self_test+0x169/0x620 [amdgpu]
    
    v2: without specifying xcp partition for PD/PT bo, the xcp id is -1.
    
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2686
    Fixes: 3ebfd221 ("drm/amdkfd: Store xcp partition id to amdgpu bo")
    Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
    Tested-by: default avatarMikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
    Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
    Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    8ecee4cb
amdgpu_vm.h 16.9 KB