All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 5/8] drm/msm/dpu: clear the DSPP pointer when no DSPP is assigned
Date: Sat, 12 Sep 2026 13:02:41 +0000	[thread overview]
Message-ID: <20260912130241.7D9AC1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260912-fd-kms-fix-smmu-v3-5-a7ddc6fe2032@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Stale pointers in dpu_enc->hw_cwb array causing uninitialized stack memory dereference
- [High] Stale pointer in dpu_enc->cur_master->hw_cdm causing hardware state corruption
--

commit 50e668cb47f95334a8bcced939d0916fe0531def
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

drm/msm/dpu: clear the DSPP pointer when no DSPP is assigned

dpu_crtc_assign_resources() only stores mixers[i].hw_dspp when the new
topology has a DSPP for that mixer, and dpu_crtc_duplicate_state() copies
the state with kmemdup(), so a crtc which once used a DSPP keeps a pointer
to it for the rest of its life -- across reservations which no longer own
that block.

Assign NULL when there is no DSPP for the mixer.

> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index bf593020e8e45..5dc0c9aeaa5d7 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1480,8 +1480,8 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,
>  
>  		cstate->mixers[i].hw_lm = to_dpu_hw_mixer(hw_lm[i]);
>  		cstate->mixers[i].lm_ctl = to_dpu_hw_ctl(hw_ctl[ctl_idx]);
> -		if (i < num_dspp)
> -			cstate->mixers[i].hw_dspp = to_dpu_hw_dspp(hw_dspp[i]);
> +		cstate->mixers[i].hw_dspp = i < num_dspp ?
> +			to_dpu_hw_dspp(hw_dspp[i]) : NULL;

[Severity: High]
This is a pre-existing issue, but does this same stale pointer problem exist
for hw_cwb in dpu_encoder_virt_atomic_mode_set() when the number of CWB
blocks decreases during a modeset?

If userspace submits a DRM commit that assigns fewer CWB blocks than the
previous state, trailing elements in dpu_enc->hw_cwb are not cleared:

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:dpu_encoder_virt_atomic_mode_set() {
    ...
	for (i = 0; i < num_cwb; i++) {
		dpu_enc->hw_cwb[i] = to_dpu_hw_cwb(hw_cwb[i]);
		cwb_mask |= BIT(dpu_enc->hw_cwb[i]->idx - CWB_0);
	}
    ...
}

Later, when dpu_encoder_helper_phys_setup_cwb() is called, it iterates over
MAX_CWB_PER_ENC and processes any non-NULL pointer. Could this cause the
driver to read from rt_pp_list[i] (an uninitialized stack array beyond
num_pp), cast the garbage value to a pointer, and dereference it via
hw_pp->idx, leading to a kernel crash?

[Severity: High]
This isn't a bug introduced by this patch, but there appears to be another
stale pointer issue in dpu_encoder_virt_atomic_mode_set() with hw_cdm:

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:dpu_encoder_virt_atomic_mode_set() {
    ...
	if ((dpu_enc->disp_info.intf_type == INTF_WB && conn_state->writeback_job) ||
	    dpu_enc->disp_info.intf_type == INTF_DP) {
		struct dpu_hw_blk *hw_cdm = NULL;

		dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
					      drm_enc->crtc, DPU_HW_BLK_CDM,
					      &hw_cdm, 1);
		dpu_enc->cur_master->hw_cdm = hw_cdm ? to_dpu_hw_cdm(hw_cdm) : NULL;
	}
    ...
}

If a modeset occurs where the encoder had a CDM block (e.g., from an active
writeback job), but the new state lacks a writeback job, the if-condition
evaluates to false and the pointer remains uncleared.

During dpu_encoder_helper_phys_cleanup(), the driver attempts to unbind the
stale CDM block by calling bind_pingpong_blk(..., PINGPONG_NONE) and
configures a flush. Can this corrupt the hardware state of a block that no
longer belongs to this reservation and may now be assigned to another display?

>  	}
>  
>  	cstate->num_mixers = num_lm;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-fd-kms-fix-smmu-v3-0-a7ddc6fe2032@oss.qualcomm.com?part=5

  reply	other threads:[~2026-09-12 13:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 12:48 [PATCH v3 0/8] drm/msm: fix SMMU fault dumps Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 1/8] drm/msm: serialise framebuffer pin state Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 2/8] drm/msm: fix framebuffer pin refcount leak on prepare failure Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 3/8] drm/msm: unwind msm_drm_kms_init() on failure Dmitry Baryshkov
2026-09-12 13:33   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 4/8] drm/msm: release scanout framebuffers only after a vblank Dmitry Baryshkov
2026-09-12 12:59   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 5/8] drm/msm/dpu: clear the DSPP pointer when no DSPP is assigned Dmitry Baryshkov
2026-09-12 13:02   ` sashiko-bot [this message]
2026-09-12 12:48 ` [PATCH v3 6/8] drm/msm/dpu: clear the DSC blocks left by a previous reservation Dmitry Baryshkov
2026-09-12 12:59   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 7/8] drm/msm/dpu: only reassign resources when the encoder is reprogrammed Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 8/8] drm/ci: mark pixel-format tests as passing on SC7180 Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260912130241.7D9AC1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.