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
..
2023-02-06 09:29:03 +01:00
2023-01-19 16:24:04 +01:00
2023-01-29 11:17:34 -08:00
2022-12-13 15:22:14 -08:00
2023-01-14 07:38:48 +09:00
2022-12-25 13:38:09 -08:00
2023-01-19 17:27:36 +01:00
2023-01-27 16:16:57 -08:00
2023-01-17 15:59:02 -08:00
2022-12-16 03:49:24 -08:00
2023-01-12 17:02:20 -06:00
2022-12-13 13:46:07 -08:00
2022-12-12 12:52:02 -08:00
2023-01-19 17:24:47 +01:00
2022-11-26 16:49:28 -05:00
2023-01-10 20:31:08 +01:00
2022-12-19 07:13:33 -06:00
2023-01-12 05:56:06 -06:00
2023-01-25 15:35:26 -08:00
2022-11-21 15:34:40 -08:00
2022-12-05 21:57:20 +09:00
2023-01-19 18:59:34 +05:30
2023-02-17 09:16:34 +01:00
2023-01-20 19:47:34 +01:00
2022-12-16 03:49:24 -08:00
2023-01-31 12:23:23 +01:00
2022-12-16 03:49:24 -08:00
2022-11-25 13:01:55 -05:00
2022-11-24 17:12:15 +01:00
2023-01-27 14:05:38 +01:00
2023-02-23 17:35:58 -05:00
2023-01-18 14:44:32 -08:00
2022-11-25 01:04:21 +01:00
2022-12-13 15:47:48 -08:00
2022-12-13 13:09:38 -08:00
2022-11-28 18:29:53 +00:00
2023-01-20 10:18:51 +01:00
2022-12-11 21:25:58 +01:00
2022-12-16 03:49:24 -08:00
2023-01-10 12:21:50 +02:00
2023-01-29 11:06:47 -08:00
2023-01-05 17:29:57 +02:00
2023-01-13 13:46:32 +01:00
2022-12-14 15:23:49 -08:00
2022-12-25 13:38:09 -08:00
2022-12-25 13:38:09 -08:00
2022-11-24 23:12:18 +11:00
2022-12-21 09:31:18 -08:00
2022-12-02 17:48:04 +01:00
2023-01-27 16:09:12 -08:00
2023-01-20 17:46:01 +02:00
2022-12-27 09:54:32 +01:00
2022-12-09 10:29:58 +01:00
2022-12-21 09:19:24 -08:00
2023-01-31 12:23:23 +01:00
2023-01-02 15:57:36 +01:00
2023-01-02 12:08:53 +01:00
2023-01-25 22:46:51 -08:00
2023-01-09 07:34:13 +00:00
2022-12-02 23:52:32 -08:00
2023-01-27 16:16:57 -08:00
2022-12-16 03:49:24 -08:00
2023-01-04 21:31:59 -06:00
2022-12-17 23:19:38 +01:00
2023-01-13 17:32:22 -06:00
2022-12-25 13:38:09 -08:00
2023-01-26 13:55:38 +00:00
2023-01-18 22:58:05 +05:30
2023-01-17 14:16:45 +01:00
2023-01-25 12:45:16 +01:00
2022-11-25 19:36:52 +01:00
2022-12-17 08:39:31 -06:00
2022-12-02 20:49:49 +01:00
2022-11-24 23:31:47 +11:00
2022-12-13 15:47:48 -08:00
2022-12-21 09:41:28 -08:00
2022-12-11 19:30:20 -08:00
2023-01-03 15:54:38 +00:00
2022-12-07 11:20:55 -07:00
2023-01-03 11:30:46 +01:00
2022-12-21 09:19:24 -08:00
2023-01-06 13:12:42 -08:00
2022-11-19 00:56:15 +01:00
2023-01-24 17:42:53 -08:00
2022-11-23 19:45:33 +01:00
2023-01-10 23:09:09 +01:00
2022-12-19 08:47:33 -06:00
2023-01-11 14:15:22 +00:00
2023-01-17 19:23:36 +01:00
2023-01-13 20:24:24 -05:00
2022-12-12 10:17:08 -08:00
2023-01-25 15:37:21 +01:00
2023-01-09 10:44:43 +02:00
2023-01-21 11:12:42 -08:00
2023-01-18 19:08:37 -05:00
2023-01-21 11:10:03 -08:00
2022-12-28 05:28:11 -05:00
2023-01-10 10:44:37 -07:00
2022-12-28 05:28:11 -05:00
2023-01-31 12:23:23 +01:00
2022-12-16 03:49:24 -08:00
2022-12-28 05:28:11 -05:00
2023-01-19 17:26:33 +01:00
2022-12-17 08:34:01 -06:00
2023-01-12 17:02:20 -06:00
2022-11-22 13:13:51 +02:00
2023-01-26 11:52:10 +02:00