Alex Deucher
20880a3fd5
drm/amdgpu: fix a job->pasid access race in gpu recovery
Avoid a possible UAF in GPU recovery due to a race between
the sched timeout callback and the tdr work queue.
The gpu recovery function calls drm_sched_stop() and
later drm_sched_start(). drm_sched_start() restarts
the tdr queue which will eventually free the job. If
the tdr queue frees the job before time out callback
completes, the job will be freed and we'll get a UAF
when accessing the pasid. Cache it early to avoid the
UAF.
Example KASAN trace:
[ 493.058141] BUG: KASAN: slab-use-after-free in amdgpu_device_gpu_recover+0x968/0x990 [amdgpu]
[ 493.067530] Read of size 4 at addr ffff88b0ce3f794c by task kworker/u128:1/323
[ 493.074892]
[ 493.076485] CPU: 9 UID: 0 PID: 323 Comm: kworker/u128:1 Tainted: G E 6.16.0-1289896.2.zuul.bf4f11df81c1410bbe901c4373305a31 #1 PREEMPT(voluntary)
[ 493.076493] Tainted: [E]=UNSIGNED_MODULE
[ 493.076495] Hardware name: TYAN B8021G88V2HR-2T/S8021GM2NR-2T, BIOS V1.03.B10 04/01/2019
[ 493.076500] Workqueue: amdgpu-reset-dev drm_sched_job_timedout [gpu_sched]
[ 493.076512] Call Trace:
[ 493.076515] <TASK>
[ 493.076518] dump_stack_lvl+0x64/0x80
[ 493.076529] print_report+0xce/0x630
[ 493.076536] ? _raw_spin_lock_irqsave+0x86/0xd0
[ 493.076541] ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[ 493.076545] ? amdgpu_device_gpu_recover+0x968/0x990 [amdgpu]
[ 493.077253] kasan_report+0xb8/0xf0
[ 493.077258] ? amdgpu_device_gpu_recover+0x968/0x990 [amdgpu]
[ 493.077965] amdgpu_device_gpu_recover+0x968/0x990 [amdgpu]
[ 493.078672] ? __pfx_amdgpu_device_gpu_recover+0x10/0x10 [amdgpu]
[ 493.079378] ? amdgpu_coredump+0x1fd/0x4c0 [amdgpu]
[ 493.080111] amdgpu_job_timedout+0x642/0x1400 [amdgpu]
[ 493.080903] ? pick_task_fair+0x24e/0x330
[ 493.080910] ? __pfx_amdgpu_job_timedout+0x10/0x10 [amdgpu]
[ 493.081702] ? _raw_spin_lock+0x75/0xc0
[ 493.081708] ? __pfx__raw_spin_lock+0x10/0x10
[ 493.081712] drm_sched_job_timedout+0x1b0/0x4b0 [gpu_sched]
[ 493.081721] ? __pfx__raw_spin_lock_irq+0x10/0x10
[ 493.081725] process_one_work+0x679/0xff0
[ 493.081732] worker_thread+0x6ce/0xfd0
[ 493.081736] ? __pfx_worker_thread+0x10/0x10
[ 493.081739] kthread+0x376/0x730
[ 493.081744] ? __pfx_kthread+0x10/0x10
[ 493.081748] ? __pfx__raw_spin_lock_irq+0x10/0x10
[ 493.081751] ? __pfx_kthread+0x10/0x10
[ 493.081755] ret_from_fork+0x247/0x330
[ 493.081761] ? __pfx_kthread+0x10/0x10
[ 493.081764] ret_from_fork_asm+0x1a/0x30
[ 493.081771] </TASK>
Fixes: a72002cb18 ("drm/amdgpu: Make use of drm_wedge_task_info")
Link: https://github.com/HansKristian-Work/vkd3d-proton/pull/2670
Cc: SRINIVASAN.SHANMUGAM@amd.com
Cc: vitaly.prosyak@amd.com
Cc: christian.koenig@amd.com
Suggested-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2025-12-16 13:26:31 -05:00
..
2025-11-13 09:10:43 -08:00
2025-11-14 13:25:00 -08:00
2025-10-22 08:04:15 +02:00
2025-10-13 09:12:36 +02:00
2025-08-22 17:23:15 -07:00
2025-11-01 10:45:39 -07:00
2025-10-20 13:54:15 +02:00
2025-10-31 12:57:19 -07:00
2025-11-11 09:06:57 -05:00
2025-10-04 16:26:32 -07:00
2025-09-11 19:13:21 +01:00
2025-10-04 16:26:32 -07:00
2025-10-18 14:33:22 +03:00
2025-10-07 09:28:37 -07:00
2025-10-07 08:40:15 -07:00
2025-10-22 08:03:52 +02:00
2025-08-24 17:02:03 +09:00
2025-11-12 17:59:37 +01:00
2025-11-06 15:44:18 -08:00
2025-11-06 14:29:49 +08:00
2025-11-07 09:22:10 -07:00
2025-09-15 16:09:42 +02:00
2025-10-15 10:39:54 -04:00
2025-09-26 15:10:59 -07:00
2025-10-06 10:37:06 -07:00
2025-12-02 18:09:08 +10:00
2025-10-28 18:54:48 -07:00
2025-11-11 14:59:04 +01:00
2025-09-08 15:13:06 +09:00
2025-11-16 21:30:26 +09:00
2025-10-23 22:30:01 +02:00
2025-08-19 12:54:45 +02:00
2025-09-22 10:33:10 -03:00
2025-11-06 18:19:44 +01:00
2025-12-16 13:26:31 -05:00
2025-08-19 12:50:31 +02:00
2025-10-18 08:18:18 -10:00
2025-09-05 22:56:59 +02:00
2025-10-01 00:00:45 +00:00
2025-11-12 11:54:37 -08:00
2025-10-04 16:26:32 -07:00
2025-11-03 18:04:15 +01:00
2025-09-29 00:17:22 +02:00
2025-09-01 17:32:25 +02:00
2025-09-23 14:15:25 +02:00
2025-11-11 15:12:18 +01:00
2025-10-08 09:44:38 -07:00
2025-09-12 13:54:17 +03:00
2025-11-05 15:11:26 -04:00
2025-11-14 16:52:34 +01:00
2025-10-31 17:39:14 -07:00
2025-09-16 16:49:28 +01:00
2025-10-08 11:44:21 -07:00
2025-10-03 18:48:02 -07:00
2025-10-24 11:16:26 +02:00
2025-09-10 11:40:44 +02:00
2025-10-02 18:18:33 -07:00
2025-08-13 02:59:28 -04:00
2025-10-03 10:38:23 -05:00
2025-10-26 10:33:46 -07:00
2025-11-11 17:47:47 +01:00
2025-10-22 08:04:43 +02:00
2025-10-04 15:50:37 -07:00
2025-11-13 13:16:30 +01:00
2025-08-18 17:29:08 -07:00
2025-09-22 09:35:21 -04:00
2025-10-06 11:17:18 -07:00
2025-10-22 19:46:25 -07:00
2025-10-22 08:02:38 +02:00
2025-10-24 07:44:09 -05:00
2025-08-26 10:40:58 +05:30
2025-08-19 12:41:18 +02:00
2025-11-14 15:45:31 -08:00
2025-08-16 15:49:58 +02:00
2025-08-28 22:43:23 +02:00
2025-10-07 08:59:25 -07:00
2025-10-06 10:34:22 -07:00
2025-10-06 10:41:03 -07:00
2025-11-05 11:08:10 -08:00
2025-11-04 17:29:00 +01:00
2025-08-25 17:30:16 +02:00
2025-10-01 13:02:59 -07:00
2025-08-21 21:57:54 +02:00
2025-09-06 16:00:40 +02:00
2025-09-06 17:01:26 +05:30
2025-10-31 16:27:40 -07:00
2025-10-01 11:34:12 -07:00
2025-09-15 16:20:29 +02:00
2025-11-05 11:56:16 +00:00
2025-10-04 15:45:17 -07:00
2025-10-01 17:32:51 -07:00
2025-09-20 21:29:48 -05:00
2025-11-08 20:56:12 +01:00
2025-10-09 10:51:43 -07:00
2025-10-21 21:09:36 -04:00
2025-09-06 15:59:59 +02:00
2025-09-12 15:47:38 +02:00
2025-11-04 19:15:36 -08:00
2025-10-06 10:32:22 -07:00
2025-11-10 14:03:53 +00:00
2025-08-07 10:07:06 +02:00
2025-10-13 10:55:03 +02:00
2025-10-11 11:49:00 -07:00
2025-10-17 15:26:52 +02:00
2025-10-02 10:41:58 +02:00
2025-09-23 17:16:38 +02:00
2025-10-22 12:13:54 +02:00
2025-10-29 23:20:19 -04:00
2025-10-07 08:40:15 -07:00
2025-10-24 13:52:58 +02:00
2025-11-11 15:12:18 +01:00
2025-12-01 09:45:48 +01:00
2025-10-01 07:24:43 -04:00
2025-11-21 08:55:08 +10:00
2025-09-29 18:48:39 -07:00
2025-10-04 08:48:16 -07:00
2025-08-31 14:14:07 +02:00
2025-10-06 11:00:30 -07:00
2025-10-03 17:41:12 -07:00
2025-09-15 14:30:17 +02:00
2025-10-07 08:40:15 -07:00