lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0788b245-ee8f-25de-dde3-7ff10f6c688c@linaro.org>
Date:   Mon, 11 Apr 2022 03:56:31 +0300
From:   Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To:     Xiaomeng Tong <xiam0nd.tong@...il.com>, robdclark@...il.com,
        sean@...rly.run, airlied@...ux.ie, daniel@...ll.ch
Cc:     quic_abhinavk@...cinc.com, swboyd@...omium.org,
        bjorn.andersson@...aro.org, quic_khsieh@...cinc.com,
        quic_kalyant@...cinc.com, markyacoub@...gle.com,
        jsanka@...eaurora.org, linux-arm-msm@...r.kernel.org,
        dri-devel@...ts.freedesktop.org, freedreno@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] dpu1: dpu_encoder: fix a missing check on list iterator

On 27/03/2022 10:32, Xiaomeng Tong wrote:
> The bug is here:
> 	 cstate = to_dpu_crtc_state(drm_crtc->state);
> 
> For the drm_for_each_crtc(), just like list_for_each_entry(),
> the list iterator 'drm_crtc' will point to a bogus position
> containing HEAD if the list is empty or no element is found.
> This case must be checked before any use of the iterator,
> otherwise it will lead to a invalid memory access.
> 
> To fix this bug, use a new variable 'iter' as the list iterator,
> while use the origin variable 'drm_crtc' as a dedicated pointer
> to point to the found element.
> 
> Cc: stable@...r.kernel.org
> Fixes: b107603b4ad0f ("drm/msm/dpu: map mixer/ctl hw blocks in encoder modeset")
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@...il.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>

> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 1e648db439f9..d3fdb18e96f9 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -965,7 +965,7 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc,
>   	struct dpu_kms *dpu_kms;
>   	struct list_head *connector_list;
>   	struct drm_connector *conn = NULL, *conn_iter;
> -	struct drm_crtc *drm_crtc;
> +	struct drm_crtc *drm_crtc = NULL, *iter;
>   	struct dpu_crtc_state *cstate;
>   	struct dpu_global_state *global_state;
>   	struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC];
> @@ -1007,9 +1007,14 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc,
>   		return;
>   	}
>   
> -	drm_for_each_crtc(drm_crtc, drm_enc->dev)
> -		if (drm_crtc->state->encoder_mask & drm_encoder_mask(drm_enc))
> +	drm_for_each_crtc(iter, drm_enc->dev)
> +		if (iter->state->encoder_mask & drm_encoder_mask(drm_enc)) {
> +			drm_crtc = iter;
>   			break;
> +		}
> +
> +	if (!drm_crtc)
> +		return;
>   
>   	/* Query resource that have been reserved in atomic check step. */
>   	num_pp = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,


-- 
With best wishes
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ