Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v8 14/14] drm/i915/display: use drm backlight
Date: Tue, 08 Sep 2026 05:03:37 +0000	[thread overview]
Message-ID: <20260908050338.4ED111F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908044035.62093-15-mario.limonciello@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unprotected access to `crtc->state` in `drm_atomic_helper_connector_apply_luminance` leading to Use-After-Free.
--

commit 4d692fcf914aa54e6baac83f8855bd80382896c8
Author: Mario Limonciello <mario.limonciello@amd.com>
Subject: drm/i915/display: use drm backlight

Convert the Intel display drivers to the DRM backlight infrastructure so
brightness can be controlled through the connector LUMINANCE property. The
DRM core owns the embedded backlight state and its property.

> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 9dfd095f325f7..d53e5f4bdf57d 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
[ ... ]
> @@ -7608,6 +7610,9 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>  	display->modeset.funcs->commit_modeset_enables(state);
>  
> +	for_each_new_connector_in_state(&state->base, connector, new_conn_state, i)
> +		drm_atomic_helper_connector_apply_luminance(new_conn_state);
> +

[Severity: High]
Could this lead to a Use-After-Free of the CRTC state?

When userspace updates only the LUMINANCE property, the CRTC is not pulled
into the atomic state, meaning crtc->mutex is never locked and no
serialization dependencies are established.

In intel_atomic_commit_tail(), we call
drm_atomic_helper_connector_apply_luminance() which dereferences the
global CRTC state:

drivers/gpu/drm/drm_atomic_helper.c:drm_atomic_helper_connector_apply_luminance() {
	struct drm_connector *connector = conn_state->connector;

	if (conn_state->crtc && conn_state->crtc->state &&
	    conn_state->crtc->state->active)
		drm_backlight_set_luminance(connector, conn_state->luminance);
}

Since the LUMINANCE commit executes concurrently with no CRTC
synchronization, another thread performing a modeset or DPMS update could
simultaneously acquire crtc->mutex, call drm_atomic_helper_swap_state(),
and free the old CRTC state while this code evaluates ->active.

Is this safe without acquiring the CRTC lock or pulling the CRTC into the
atomic transaction?

>  	intel_display_power_dc3co_compute(state);
>  
>  	/* FIXME probably need to sequence this properly */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908044035.62093-1-mario.limonciello@amd.com?part=14

  reply	other threads:[~2026-09-08  5:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  4:40 [PATCH v8 00/14] Add support for a DRM backlight capability Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 01/14] Revert "backlight: Remove notifier" Mario Limonciello
2026-09-08  4:51   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 02/14] backlight: add kernel-internal backlight API Mario Limonciello
2026-09-08  4:52   ` sashiko-bot
2026-09-08 15:45   ` Jani Nikula
2026-09-08 16:00     ` Mario Limonciello
2026-09-08 16:33       ` Jani Nikula
2026-09-08  4:40 ` [PATCH v8 03/14] drm/property: add a per-connector luminance flag Mario Limonciello
2026-09-08  4:54   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 04/14] drm: add connector backlight (LUMINANCE) infrastructure Mario Limonciello
2026-09-08  4:54   ` sashiko-bot
2026-09-08 15:48   ` Jani Nikula
2026-09-08  4:40 ` [PATCH v8 05/14] drm: add DRM_CLIENT_CAP_LUMINANCE Mario Limonciello
2026-09-08  4:55   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 06/14] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 07/14] drm/amd: Indicate driver supports luminance Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 08/14] drm/amd/display: use drm backlight Mario Limonciello
2026-09-08  4:57   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 09/14] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello
2026-09-08  4:51   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 10/14] drm/amd/display: Update KUnit backlight tests for luminance property and fixtures Mario Limonciello
2026-09-08  4:54   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 11/14] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 12/14] drm/xe: Indicate support for luminance on the connector Mario Limonciello
2026-09-08  4:57   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 13/14] drm/i915: " Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 14/14] drm/i915/display: use drm backlight Mario Limonciello
2026-09-08  5:03   ` sashiko-bot [this message]
2026-09-08  9:32 ` ✓ i915.CI.BAT: success for Add support for a DRM backlight capability (rev3) Patchwork
2026-09-08 18:45 ` ✗ i915.CI.Full: failure " Patchwork

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=20260908050338.4ED111F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mario.limonciello@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox