diff --git a/patches.suse/drm-amd-display-perform-a-bounds-check-before-fillin.patch b/patches.suse/drm-amd-display-perform-a-bounds-check-before-fillin.patch new file mode 100644 index 0000000..bc62bc6 --- /dev/null +++ b/patches.suse/drm-amd-display-perform-a-bounds-check-before-fillin.patch @@ -0,0 +1,72 @@ +From af22d6a869cc26b519bfdcd54293c53f2e491870 Mon Sep 17 00:00:00 2001 +From: Hamza Mahfooz +Date: Wed, 21 Jun 2023 15:19:05 -0400 +Subject: [PATCH] drm/amd/display: perform a bounds check before filling dirty rectangles +Git-commit: af22d6a869cc26b519bfdcd54293c53f2e491870 +Patch-mainline: v6.5-rc1 +References: git-fixes + +Currently, it is possible for us to access memory that we shouldn't. +Since, we acquire (possibly dangling) pointers to dirty rectangles +before doing a bounds check to make sure we can actually accommodate the +number of dirty rectangles userspace has requested to fill. This issue +is especially evident if a compositor requests both MPO and damage clips +at the same time, in which case I have observed a soft-hang. So, to +avoid this issue, perform the bounds check before filling a single dirty +rectangle and WARN() about it, if it is ever attempted in +fill_dc_dirty_rect(). + +Cc: stable@vger.kernel.org # 6.1+ +Fixes: 30ebe41582d1 ("drm/amd/display: add FB_DAMAGE_CLIPS support") +Reviewed-by: Leo Li +Signed-off-by: Hamza Mahfooz +Signed-off-by: Alex Deucher +Acked-by: Takashi Iwai + +--- + drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -4907,11 +4907,7 @@ static inline void fill_dc_dirty_rect(st + int32_t y, int32_t width, int32_t height, + int *i, bool ffu) + { +- if (*i > DC_MAX_DIRTY_RECTS) +- return; +- +- if (*i == DC_MAX_DIRTY_RECTS) +- goto out; ++ WARN_ON(*i >= DC_MAX_DIRTY_RECTS); + + dirty_rect->x = x; + dirty_rect->y = y; +@@ -4927,7 +4923,6 @@ static inline void fill_dc_dirty_rect(st + "[PLANE:%d] PSR SU dirty rect at (%d, %d) size (%d, %d)", + plane->base.id, x, y, width, height); + +-out: + (*i)++; + } + +@@ -5009,6 +5004,9 @@ static void fill_dc_dirty_rects(struct d + new_plane_state->plane->base.id, + bb_changed, fb_changed, num_clips); + ++ if ((num_clips + (bb_changed ? 2 : 0)) > DC_MAX_DIRTY_RECTS) ++ goto ffu; ++ + if (bb_changed) { + fill_dc_dirty_rect(new_plane_state->plane, &dirty_rects[i], + new_plane_state->crtc_x, +@@ -5038,9 +5036,6 @@ static void fill_dc_dirty_rects(struct d + new_plane_state->crtc_h, &i, false); + } + +- if (i > DC_MAX_DIRTY_RECTS) +- goto ffu; +- + flip_addrs->dirty_rect_count = i; + return; + diff --git a/series.conf b/series.conf index d46bd63..86767a4 100644 --- a/series.conf +++ b/series.conf @@ -42868,6 +42868,7 @@ patches.suse/drm-amd-pm-update-the-LC_L1_INACTIVITY-setting-to-ad.patch patches.suse/drm-amd-Disable-PSR-SU-on-Parade-0803-TCON.patch patches.suse/drm-amd-pm-add-abnormal-fan-detection-for-smu-13.0.0.patch + patches.suse/drm-amd-display-perform-a-bounds-check-before-fillin.patch patches.suse/drm-amdgpu-fix-number-of-fence-calculations.patch patches.suse/drm-amd-Don-t-try-to-enable-secure-display-TA-multip.patch patches.suse/drm-amd-display-Correct-DMUB_FW_VERSION-macro.patch