mirror_ubuntu-kernels/drivers/gpu/drm/amd/amdkfd
Qu Huang 4fc8fff378 drm/amdkfd: Fix an illegal memory access
In the kfd_wait_on_events() function, the kfd_event_waiter structure is
allocated by alloc_event_waiters(), but the event field of the waiter
structure is not initialized; When copy_from_user() fails in the
kfd_wait_on_events() function, it will enter exception handling to
release the previously allocated memory of the waiter structure;
Due to the event field of the waiters structure being accessed
in the free_waiters() function, this results in illegal memory access
and system crash, here is the crash log:

localhost kernel: RIP: 0010:native_queued_spin_lock_slowpath+0x185/0x1e0
localhost kernel: RSP: 0018:ffffaa53c362bd60 EFLAGS: 00010082
localhost kernel: RAX: ff3d3d6bff4007cb RBX: 0000000000000282 RCX: 00000000002c0000
localhost kernel: RDX: ffff9e855eeacb80 RSI: 000000000000279c RDI: ffffe7088f6a21d0
localhost kernel: RBP: ffffe7088f6a21d0 R08: 00000000002c0000 R09: ffffaa53c362be64
localhost kernel: R10: ffffaa53c362bbd8 R11: 0000000000000001 R12: 0000000000000002
localhost kernel: R13: ffff9e7ead15d600 R14: 0000000000000000 R15: ffff9e7ead15d698
localhost kernel: FS:  0000152a3d111700(0000) GS:ffff9e855ee80000(0000) knlGS:0000000000000000
localhost kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
localhost kernel: CR2: 0000152938000010 CR3: 000000044d7a4000 CR4: 00000000003506e0
localhost kernel: Call Trace:
localhost kernel: _raw_spin_lock_irqsave+0x30/0x40
localhost kernel: remove_wait_queue+0x12/0x50
localhost kernel: kfd_wait_on_events+0x1b6/0x490 [hydcu]
localhost kernel: ? ftrace_graph_caller+0xa0/0xa0
localhost kernel: kfd_ioctl+0x38c/0x4a0 [hydcu]
localhost kernel: ? kfd_ioctl_set_trap_handler+0x70/0x70 [hydcu]
localhost kernel: ? kfd_ioctl_create_queue+0x5a0/0x5a0 [hydcu]
localhost kernel: ? ftrace_graph_caller+0xa0/0xa0
localhost kernel: __x64_sys_ioctl+0x8e/0xd0
localhost kernel: ? syscall_trace_enter.isra.18+0x143/0x1b0
localhost kernel: do_syscall_64+0x33/0x80
localhost kernel: entry_SYSCALL_64_after_hwframe+0x44/0xa9
localhost kernel: RIP: 0033:0x152a4dff68d7

Allocate the structure with kcalloc, and remove redundant 0-initialization
and a redundant loop condition check.

Signed-off-by: Qu Huang <qu.huang@linux.dev>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2023-02-23 17:35:58 -05:00
..
cik_event_interrupt.c drm/amdkfd: rename kfd_process_vm_fault to kfd_dqm_evict_pasid 2022-02-09 14:14:53 -05:00
cik_int.h
cik_regs.h
cwsr_trap_handler_gfx8.asm
cwsr_trap_handler_gfx9.asm drm/amdkfd: port cwsr trap handler from dkms branch 2022-05-26 14:56:32 -04:00
cwsr_trap_handler_gfx10.asm drm/amdkfd: update GFX11 CWSR trap handler 2022-11-04 16:05:52 -04:00
cwsr_trap_handler.h drm/amdkfd: update GFX11 CWSR trap handler 2022-11-04 16:05:52 -04:00
Kconfig drm/amdkfd: Define config HSA_AMD_P2P to support peer-to-peer 2022-06-08 11:40:12 -04:00
kfd_chardev.c drm/amdkfd: Prevent user space using both svm and kfd api to register same user buffer 2023-02-14 15:47:09 -05:00
kfd_crat.c drm/amdkfd: add GC 11.0.4 KFD support 2022-11-29 11:03:36 -05:00
kfd_crat.h drm/amdkfd: Fix the warning of array-index-out-of-bounds 2022-11-04 16:05:53 -04:00
kfd_debugfs.c drm/amdgpu: add debugfs for kfd system and ttm mem used 2022-07-28 16:05:16 -04:00
kfd_device_queue_manager_cik.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_device_queue_manager_v9.c drm/amdkfd: Support process XNACK mode dynamic change 2023-01-17 16:11:51 -05:00
kfd_device_queue_manager_v10.c drm/amdkfd: Fix leftover errors and warnings 2022-02-14 15:08:40 -05:00
kfd_device_queue_manager_v11.c drm/amdkfd: Add KFD support for soc21 v3 2022-05-04 10:43:54 -04:00
kfd_device_queue_manager_vi.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_device_queue_manager.c drm/amdkfd: To fix sdma page fault issue for GC 11 2023-02-23 17:35:57 -05:00
kfd_device_queue_manager.h drm/amdkfd: Add KFD support for soc21 v3 2022-05-04 10:43:54 -04:00
kfd_device.c drm/amdkfd: simplify cases 2023-01-05 11:41:57 -05:00
kfd_doorbell.c drm/amdkfd: Fix CRIU restore op due to doorbell offset 2022-09-13 12:54:23 -04:00
kfd_events.c drm/amdkfd: Fix an illegal memory access 2023-02-23 17:35:58 -05:00
kfd_events.h drm/amdkfd: Asynchronously free events 2022-04-12 14:20:13 -04:00
kfd_flat_memory.c drm/amdkfd: Fix leftover errors and warnings 2022-02-14 15:08:40 -05:00
kfd_int_process_v9.c drm/amdkfd: Add KFD support for soc21 v3 2022-05-04 10:43:54 -04:00
kfd_int_process_v11.c drm/amdkfd: fix dropped interrupt in kfd_int_process_v11 2022-09-29 09:41:44 -04:00
kfd_interrupt.c drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b" 2022-07-29 15:17:31 -04:00
kfd_iommu.c drm/amdkfd: Cleanup kfd_dev struct 2022-10-27 15:12:09 -04:00
kfd_iommu.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_kernel_queue.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_kernel_queue.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_migrate.c drm/amdkfd: Use resource_size() helper function 2023-01-10 18:04:24 -05:00
kfd_migrate.h mm/memory.c: fix race when faulting a device private page 2022-10-12 18:51:49 -07:00
kfd_module.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_mqd_manager_cik.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_mqd_manager_v9.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_mqd_manager_v10.c drm/amdkfd: Fix leftover errors and warnings 2022-02-14 15:08:40 -05:00
kfd_mqd_manager_v11.c drm/amdkfd: To fix sdma page fault issue for GC 11 2023-02-23 17:35:57 -05:00
kfd_mqd_manager_vi.c drm/amdkfd: Fix leftover errors and warnings 2022-02-14 15:08:40 -05:00
kfd_mqd_manager.c drm/amdkfd: fix cu mask for asics with wgps 2022-06-30 15:28:03 -04:00
kfd_mqd_manager.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_packet_manager_v9.c drm/amdkfd: Use proper enum in pm_unmap_queues_v9() 2022-02-17 15:59:06 -05:00
kfd_packet_manager_vi.c drm/amdkfd: remove unneeded unmap single queue option 2022-02-14 15:08:41 -05:00
kfd_packet_manager.c drm/amdkfd: remove unneeded unmap single queue option 2022-02-14 15:08:41 -05:00
kfd_pasid.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_pm4_headers_ai.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_pm4_headers_aldebaran.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_pm4_headers_vi.h drm/amdkfd: Fix leftover errors and warnings 2022-02-14 15:08:40 -05:00
kfd_pm4_headers.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_pm4_opcodes.h drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_priv.h drm/amdkfd: Support process XNACK mode dynamic change 2023-01-17 16:11:51 -05:00
kfd_process_queue_manager.c drm/amdkfd: Fix CRIU restore op due to doorbell offset 2022-09-13 12:54:23 -04:00
kfd_process.c drm/amdkfd: Support process XNACK mode dynamic change 2023-01-17 16:11:51 -05:00
kfd_queue.c drm/amdkfd: update SPDX license header 2022-02-14 15:08:40 -05:00
kfd_smi_events.c drm/amdkfd: Asynchronously free smi_client 2022-06-30 15:31:30 -04:00
kfd_smi_events.h drm/amdkfd: Add unmap from GPU SMI event 2022-06-30 15:31:21 -04:00
kfd_svm.c Merge tag 'amd-drm-next-6.3-2023-01-13' of https://gitlab.freedesktop.org/agd5f/linux into drm-next 2023-01-16 15:04:13 +10:00
kfd_svm.h drm/amdkfd: Track unified memory when switching xnack mode 2022-09-30 11:21:14 -04:00
kfd_topology.c drm/amdkfd: Fix kernel warning during topology setup 2023-01-03 16:48:52 -05:00
kfd_topology.h drm/amdkfd: Fix the warning of array-index-out-of-bounds 2022-11-04 16:05:53 -04:00
Makefile drm/amdkfd: Add KFD support for soc21 v3 2022-05-04 10:43:54 -04:00
soc15_int.h drm/amdkfd: Add KFD support for soc21 v3 2022-05-04 10:43:54 -04:00