All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: oushixiong1025@163.com
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vkms: Skip pre_blend_color_transform when pipeline is all bypassed
Date: Wed, 09 Sep 2026 02:19:12 +0000	[thread overview]
Message-ID: <20260909021913.30B371F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909021028.105837-1-oushixiong1025@163.com>

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

Pre-existing issues:
- [High] VKMS composer accesses global colorop->state directly without shadowing it during atomic commit, leading to a data race and potential Use-After-Free.
--

commit 7feb24a5b3e1c9cb2aa23694b44e46aece887a34
Author: Shixiong Ou <oushixiong@kylinos.cn>

drm/vkms: Skip pre_blend_color_transform when pipeline is all bypassed

This patch adds an optimization to pre_blend_color_transform() to skip
the entire pixel processing loop when all colorops in the pipeline are
bypassed or the pipeline is empty.

> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 83d217085ad09..18f58569f0169 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -190,13 +190,29 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
>  	}
>  }
>  
> +static bool pipeline_all_bypassed(struct drm_colorop *colorop)
> +{
> +	while (colorop) {
> +		struct drm_colorop_state *colorop_state = colorop->state;

[Severity: High]
This is a pre-existing issue, but does this direct access to colorop->state
introduce a potential data race and use-after-free?

The VKMS composer processes frames asynchronously in a workqueue
(vkms_composer_worker). While plane states are properly duplicated and
shadowed, reading the global colorop->state pointer directly here in
pipeline_all_bypassed() within drivers/gpu/drm/vkms/vkms_composer.c seems
unsafe.

If a non-blocking atomic commit swaps the state via
drm_atomic_helper_swap_state() and frees the old state via
drm_atomic_state_put() while the composer worker is preempted, will the
worker dereference a freed state pointer when it resumes? Local userspace
with DRM master privileges could potentially trigger this by submitting rapid
non-blocking atomic commits that modify the color pipeline while the virtual
hardware is compositing frames.

This same unsafe access pattern already exists in the inner loop of
pre_blend_color_transform(), but this patch expands the pattern into the new
pipeline_all_bypassed() function. Should the colorop state be properly
shadowed for the atomic commit instead of being read globally?

> +
> +		if (!colorop_state || !colorop_state->bypass)
> +			return false;
> +		colorop = colorop->next;
> +	}
> +	return true;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909021028.105837-1-oushixiong1025@163.com?part=1

      reply	other threads:[~2026-09-09  2:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  2:10 [PATCH] drm/vkms: Skip pre_blend_color_transform when pipeline is all bypassed oushixiong1025
2026-09-09  2:19 ` sashiko-bot [this message]

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=20260909021913.30B371F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=oushixiong1025@163.com \
    --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.