Skip to content

Fix array-index-out-of-bounds in intel_cmtg_disable()

Animesh Manna intel-gfx intel-xe 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v11 patch 1 replySuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2drm/i915/display: Guard CMTG disable with intel_cmtg_is_allowed()drivers/gpu/drm/i915/display/intel_display.c+3 -21 reply
2/2drm/i915/cmtg: Warn on invalid CMTG transcoder in intel_cmtg_disable()drivers/gpu/drm/i915/display/intel_cmtg.c+3 -01 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSuraj Kandpal
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Fix array-index-out-of-bounds in intel_cmtg_disable()

intel_cmtg_disable() maps crtc_state->cpu_transcoder to a CMTG transcoder via to_cmtg_transcoder(), which only returns a valid transcoder for TRANSCODER_A/B. The disable call sites only checked the sticky crtc->cmtg.enabled flag, so during a big-joiner reconfiguration that moves the eDP across pipes intel_cmtg_disable() could be reached with a cpu_transcoder that does not map to a CMTG transcoder. That led to a negative register-array index (trans_offsets[-1]) and a UBSAN array-index-out-of-bounds splat.

v1 fixed this with a silent early return inside intel_cmtg_disable(). Following review feedback, v2 instead gates the call sites with intel_cmtg_is_allowed() (the actual fix) and keeps a drm_WARN_ON() inside intel_cmtg_disable() as a backstop that documents the invariant.

The patches are ordered so that the series stays splat-free at every step:
patch 1 prevents any invalid call from reaching intel_cmtg_disable(), and patch 2 then adds the drm_WARN_ON() that should never fire in normal operation.

Animesh Manna (2):
drm/i915/display: Guard CMTG disable with intel_cmtg_is_allowed() drm/i915/cmtg: Warn on invalid CMTG transcoder in intel_cmtg_disable()

 drivers/gpu/drm/i915/display/intel_cmtg.c    | 3 +++
 drivers/gpu/drm/i915/display/intel_display.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.29.0