kernel_samsung_a53x/drivers/gpu/drm/i915/gt
Janusz Krzysztofik 0ecec1bda2 drm/i915/gt: Fix potential UAF by revoke of fence registers
commit 996c3412a06578e9d779a16b9e79ace18125ab50 upstream.

CI has been sporadically reporting the following issue triggered by
igt@i915_selftest@live@hangcheck on ADL-P and similar machines:

<6> [414.049203] i915: Running intel_hangcheck_live_selftests/igt_reset_evict_fence
...
<6> [414.068804] i915 0000:00:02.0: [drm] GT0: GUC: submission enabled
<6> [414.068812] i915 0000:00:02.0: [drm] GT0: GUC: SLPC enabled
<3> [414.070354] Unable to pin Y-tiled fence; err:-4
<3> [414.071282] i915_vma_revoke_fence:301 GEM_BUG_ON(!i915_active_is_idle(&fence->active))
...
<4>[  609.603992] ------------[ cut here ]------------
<2>[  609.603995] kernel BUG at drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c:301!
<4>[  609.604003] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
<4>[  609.604006] CPU: 0 PID: 268 Comm: kworker/u64:3 Tainted: G     U  W          6.9.0-CI_DRM_14785-g1ba62f8cea9c+ #1
<4>[  609.604008] Hardware name: Intel Corporation Alder Lake Client Platform/AlderLake-P DDR4 RVP, BIOS RPLPFWI1.R00.4035.A00.2301200723 01/20/2023
<4>[  609.604010] Workqueue: i915 __i915_gem_free_work [i915]
<4>[  609.604149] RIP: 0010:i915_vma_revoke_fence+0x187/0x1f0 [i915]
...
<4>[  609.604271] Call Trace:
<4>[  609.604273]  <TASK>
...
<4>[  609.604716]  __i915_vma_evict+0x2e9/0x550 [i915]
<4>[  609.604852]  __i915_vma_unbind+0x7c/0x160 [i915]
<4>[  609.604977]  force_unbind+0x24/0xa0 [i915]
<4>[  609.605098]  i915_vma_destroy+0x2f/0xa0 [i915]
<4>[  609.605210]  __i915_gem_object_pages_fini+0x51/0x2f0 [i915]
<4>[  609.605330]  __i915_gem_free_objects.isra.0+0x6a/0xc0 [i915]
<4>[  609.605440]  process_scheduled_works+0x351/0x690
...

In the past, there were similar failures reported by CI from other IGT
tests, observed on other platforms.

Before commit 63baf4f3d587 ("drm/i915/gt: Only wait for GPU activity
before unbinding a GGTT fence"), i915_vma_revoke_fence() was waiting for
idleness of vma->active via fence_update().   That commit introduced
vma->fence->active in order for the fence_update() to be able to wait
selectively on that one instead of vma->active since only idleness of
fence registers was needed.  But then, another commit 0d86ee35097a
("drm/i915/gt: Make fence revocation unequivocal") replaced the call to
fence_update() in i915_vma_revoke_fence() with only fence_write(), and
also added that GEM_BUG_ON(!i915_active_is_idle(&fence->active)) in front.
No justification was provided on why we might then expect idleness of
vma->fence->active without first waiting on it.

The issue can be potentially caused by a race among revocation of fence
registers on one side and sequential execution of signal callbacks invoked
on completion of a request that was using them on the other, still
processed in parallel to revocation of those fence registers.  Fix it by
waiting for idleness of vma->fence->active in i915_vma_revoke_fence().

Fixes: 0d86ee35097a ("drm/i915/gt: Make fence revocation unequivocal")
Closes: https://gitlab.freedesktop.org/drm/intel/issues/10021
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: stable@vger.kernel.org # v5.8+
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240603195446.297690-2-janusz.krzysztofik@linux.intel.com
(cherry picked from commit 24bb052d3dd499c5956abad5f7d8e4fd07da7fb1)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 14:19:34 +01:00
..
selftests Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
shaders Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_engines.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_engines.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_gt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_gt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_gt_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debugfs_gt_pm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen2_engine_cs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen2_engine_cs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen6_engine_cs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen6_engine_cs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen6_ppgtt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen6_ppgtt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen6_renderstate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen7_renderclear.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen7_renderclear.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen7_renderstate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen8_ppgtt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen8_ppgtt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen8_renderstate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gen9_renderstate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hsw_clear_kernel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_breadcrumbs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_breadcrumbs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_breadcrumbs_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context_param.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context_param.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context_sseu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_context_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_cs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_heartbeat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_heartbeat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_pm.c drm/i915/gt: Reset queue_priority_hint on parking 2024-11-19 09:23:15 +01:00
intel_engine_pm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_user.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_engine_user.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ggtt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ggtt_fencing.c drm/i915/gt: Fix potential UAF by revoke of fence registers 2024-11-19 14:19:34 +01:00
intel_ggtt_fencing.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gpu_commands.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_buffer_pool.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_buffer_pool.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_buffer_pool_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_clock_utils.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_clock_utils.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_irq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_irq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_pm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_pm_irq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_pm_irq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_requests.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_requests.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gt_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gtt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_gtt.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_llc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_llc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_llc_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_lrc.c drm/i915/gt: Reset queue_priority_hint on parking 2024-11-19 09:23:15 +01:00
intel_lrc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_lrc_reg.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_mocs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_mocs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ppgtt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rc6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rc6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rc6_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_renderstate.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_renderstate.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_reset.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_reset.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_reset_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ring.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ring.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ring_submission.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_ring_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rps.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_rps_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_sseu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_sseu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_sseu_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_sseu_debugfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_timeline.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_timeline.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_timeline_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_workarounds.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_workarounds.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
intel_workarounds_types.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ivb_clear_kernel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mock_engine.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mock_engine.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_context.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine_cs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine_heartbeat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine_heartbeat.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_engine_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_gt_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_hangcheck.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_llc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_llc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_lrc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_mocs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_rc6.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_rc6.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_reset.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_ring.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_ring_submission.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_rps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_rps.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_timeline.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftest_workarounds.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
shmem_utils.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
shmem_utils.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
st_shmem_utils.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfs_engines.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfs_engines.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00