[lvc-project] [PATCH] drm/dp: backport: Fix OOB read when handling Post Cursor2 register

Fedor Pchelkin pchelkin at ispras.ru
Tue Mar 25 11:54:53 MSK 2025


Перенос коммита из upstream-репозитория в stable-ветку освещён в
https://portal.linuxtesting.ru/How-to-send-patches-to-kernel.html#Перенос-патчей-в-стабильную-ветку-ядра

Название патча остаётся неизменным. Целевые ветки указываются в
[PATCH 5.10] или [PATCH 5.10/5.15/6.1] формате.

On Tue, 25. Mar 00:22, Alexey V. Vissarionov wrote:

From: Kees Cook <kees at kernel.org>

commit a2151490cc6c57b368d7974ffd447a8b36ade639 upstream.

Дальнейшее описание вставляется без изменений, вместе со всеми исходными
подписями, reviewed-by и прочими. В конце ставится подпись бэкпортёра.

> The link_status array was not large enough to read the Adjust
> Request Post Cursor2 register, so remove the common helper
> function to avoid an OOB read.
> 
> Replace the only use of the helper with an explicit fetch and
> decode.
> 
> Fixes: drm/dp: Add helper to get post-cursor adjustments
> Signed-off-by: Alexey V. Vissarionov <gremlin at altlinux.org>
> 

Просьба сделать так, чтобы здесь были три чёрточки. Иначе все
стандартные скрипты ядра по работе с патчами не понимают, где кончается
changelog коммита.

---

> diff --git a/drivers/gpu/drm/tegra/dp.c b/drivers/gpu/drm/tegra/dp.c
> index 70dfb7d1dec55a53..f5535eb04c6b1df2 100644
> --- a/drivers/gpu/drm/tegra/dp.c
> +++ b/drivers/gpu/drm/tegra/dp.c
> @@ -549,6 +549,15 @@ static void drm_dp_link_get_adjustments(struct drm_dp_link *link,
>  {
>  	struct drm_dp_link_train_set *adjust = &link->train.adjust;
>  	unsigned int i;
> +	u8 post_cursor;
> +	int err;
> +
> +	err = drm_dp_dpcd_read(link->aux, DP_ADJUST_REQUEST_POST_CURSOR2,
> +			       &post_cursor, sizeof(post_cursor));
> +	if (err < 0) {
> +		DRM_ERROR("failed to read post_cursor2: %d\n", err);
> +		post_cursor = 0;
> +	}
>  
>  	for (i = 0; i < link->lanes; i++) {
>  		adjust->voltage_swing[i] =
> @@ -560,7 +569,7 @@ static void drm_dp_link_get_adjustments(struct drm_dp_link *link,
>  				DP_TRAIN_PRE_EMPHASIS_SHIFT;
>  
>  		adjust->post_cursor[i] =
> -			drm_dp_get_adjust_request_post_cursor(status, i);
> +			(post_cursor >> (i << 1)) & 0x3;
>  	}
>  }
>  
> 
> 
> -- 
> Alexey V. Vissarionov
> gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
> GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net
> 
> _______________________________________________
> lvc-project mailing list
> lvc-project at linuxtesting.org
> http://linuxtesting.org/cgi-bin/mailman/listinfo/lvc-project



More information about the lvc-project mailing list