[PATCH] drm/meson: skip invisible planes in atomic_update
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Dec 4 18:34:01 PST 2026
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/meson: invisible plane skip leaves OSD1 enabled causing DMA
UAF
- [Low] drm/meson: Fixes tag cites bbbe775ec5b5 instead of 7db647aa8b13
--
commit 2897024e4c3710997999b1de11959966a195a61b
Author: Shirong Zhao <shxzhaosr at 163.com>
> drm/meson: skip invisible planes in atomic_update
>
> meson_plane_atomic_update() computes the scaler phase steps as
>
> hf_phase_step = ((src_w << 18) / dst_w) << 6;
> vf_phase_step = (src_h << 20) / dst_h;
>
> without checking new_state->visible. When userspace submits a zero
> destination size through the atomic ioctl,
> drm_atomic_helper_check_plane_state() marks the plane invisible but
> drm_atomic_helper_commit_planes() still calls ->atomic_update() for a
> plane that keeps its CRTC, so dst_w/dst_h can be 0 and the divisions
> above raise a divide error.
>
> Return early for an invisible plane.
>
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Signed-off-by: Shirong Zhao <shxzhaosr at 163.com>
[Severity: Low]
Should the Fixes tag cite 7db647aa8b13 ("drm/meson: Add primary plane
scaling") instead? Commit bbbe775ec5b5 ("drm: Add support for Amlogic
Meson Graphic Controller") did not have the scaler phase-step divisions
by dst_w and dst_h.
> diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
> index c17afe6712f93..80d685b875a74 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -152,6 +152,15 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> int vf_bank_len;
> u8 canvas_id_osd1;
>
> + /*
> + * A zero destination size makes the plane invisible, but
> + * drm_atomic_helper_commit_planes() still calls ->atomic_update() for
> + * planes that keep their CRTC. The scaler factor computation below
> + * divides by dst_w/dst_h, so bail out for an invisible plane.
> + */
> + if (!new_state->visible)
> + return;
> +
> /*
> * Update Coordinates
> * Update Formats
[Severity: High]
Does returning early here leave OSD1 enabled and scanning out the
previous framebuffer's DMA address?
When a visible plane becomes invisible while keeping its CRTC,
drm_atomic_helper_commit_planes() skips ->atomic_disable() and calls
meson_plane_atomic_update() instead. Bailing out leaves
priv->viu.osd1_enabled true and priv->viu.osd1_addr set to the old buffer.
meson_crtc_atomic_flush() then still sets priv->viu.osd1_commit, so
meson_crtc_irq() keeps programming OSD1 with that stale address. If the
commit replaced the framebuffer, freeing the old GEM buffer results in a
DMA use-after-free while OSD1 continues scanning it out.
Calling meson_plane_atomic_disable(plane, state) before returning would
disable OSD1 and clear priv->viu.osd1_enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205021754.64-1-shxzhaosr@163.com?part=1
More information about the linux-amlogic
mailing list