Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B26E606A31C for ; Sat, 28 Nov 2026 17:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d7qf++dO Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6913610E569; Sat, 28 Nov 2026 17:31:53 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 405FB10EA3E for ; Sat, 28 Nov 2026 17:31:47 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6B5DB6133B; Sat, 28 Nov 2026 17:31:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 961B01F000C1; Sat, 28 Nov 2026 17:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795887105; bh=urofrZwvSsGwWnS40is1gSzVGxSvuOPmGghr+D0Louw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=d7qf++dOTVupQDk5OGkV0RSNn5C9ClWEcCVkqlqyoLTCIkLgxertmNXLO8MtlI0l2 V0C/MwsWX7D79Rgk+LTke1bhTLlpN8N9FYo0gU1mRxpD1XFcU40HHyQeKnu1kcWM/y AzJR+eV3tiAqUO6RkGnJKvj9Ji+vibWoGgHIh87soolgSsI3ri9373ZdXFIg0TEyD7 nRqWuqUD1ULS+EHXjIhf7pHjA2+SdGpMXkpiPoM48I13PmPPEnEESNtwjMq2vjkELg OsJcSFmPoqDJ+ljN+MCb4XuyVMsQhkDMfrk0QRMILUy8Wv07d5pPbf+j6LymSFcMcB vHY8fRXqGKNcA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/7] drm/vkms: use the colorop states of the state being composed To: "Oarora Etimis" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261128-colorop-v1-3-dd79919f822b@gmail.com> References: <20261128-colorop-v1-0-dd79919f822b@gmail.com> <20261128-colorop-v1-3-dd79919f822b@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 17:31:45 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/vkms: use-after-free in vkms_plane_colorops_update() on nonblocking commit -- commit 838e4d7bd5412801fae0f59aa09cd076672b38c7 Author: Oarora Etimis drm/vkms: use the colorop states of the state being composed This commit copies each active plane's colorop state and LUT blob reference into vkms_plane_state during vkms_crtc_atomic_flush() so the asynchronous composer worker does not read drm_colorop::state directly. > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms= _crtc.c > index 7d18178d53205..e7ea487187bce 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -186,11 +187,43 @@ static void vkms_crtc_atomic_begin(struct drm_crtc = *crtc, > spin_lock_irq(&vkms_output->lock); > } > =20 > +static void vkms_plane_colorops_update(struct vkms_plane_state *plane_st= ate, > + struct drm_atomic_commit *commit) > +{ > + struct drm_colorop *colorop; > + size_t slot =3D 0; > + > + /* > + * The plane state is freshly allocated for this commit, so its > + * colorop_states array is zero and holds nothing to release. > + */ > + for (colorop =3D plane_state->base.base.color_pipeline; > + colorop && slot < ARRAY_SIZE(plane_state->colorop_states); > + colorop =3D colorop->next) { > + struct drm_colorop_state *colorop_state; > + struct vkms_colorop_state *state; > + > + colorop_state =3D drm_atomic_get_new_colorop_state(commit, colorop); > + if (!colorop_state) > + break; > + > + state =3D &plane_state->colorop_states[slot++]; > + state->colorop =3D colorop; > + state->bypass =3D colorop_state->bypass; > + state->curve_1d_type =3D colorop_state->curve_1d_type; > + state->multiplier =3D colorop_state->multiplier; > + > + if (colorop_state->data) > + state->data =3D drm_property_blob_get(colorop_state->data); > + } > +} > + > static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, > struct drm_atomic_commit *state) > __releases(&vkms_output->lock) > { > struct vkms_output *vkms_output =3D drm_crtc_to_vkms_output(crtc); > + struct vkms_crtc_state *crtc_state =3D to_vkms_crtc_state(crtc->state); > =20 > if (crtc->state->event) { > spin_lock(&crtc->dev->event_lock); > @@ -205,7 +238,15 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *= crtc, > crtc->state->event =3D NULL; > } > =20 > - vkms_output->composer_state =3D to_vkms_crtc_state(crtc->state); > + /* > + * Capture the color operations of this commit: drm_colorop::state is > + * the current value of the colorop, not the one this frame was built > + * from, and the composer runs asynchronously, so it must not read it. > + */ > + for (size_t i =3D 0; i < crtc_state->num_active_planes; i++) > + vkms_plane_colorops_update(crtc_state->active_planes[i], state); [Severity: High] Can vkms_plane_colorops_update() read a freed drm_colorop_state and take a reference on an already-released data blob when commit 1 is nonblocking? CPU0 (commit 1, nonblocking) CPU1 (commit 2, unchanged colorop prop) drm_mode_atomic_ioctl() drm_atomic_helper_commit(s1) drm_atomic_helper_swap_state(s1) colorop->state =3D cs1 queue_work(s1->commit_work) drm_modeset_drop_locks() drm_mode_atomic_ioctl() drm_atomic_set_property() drm_atomic_get_colorop_state(s2) /* !replaced: plane not added to s2 */ drm_atomic_helper_commit(s2) /* no plane/CRTC in s2, no stall */ drm_atomic_helper_swap_state(s2) s2->...->state_to_destroy =3D cs1 drm_atomic_commit_put(s2) drm_colorop_Passed/destroy_state(cs1) drm_property_blob_put(cs1->data) kfree(cs1) commit_work() drm_atomic_helper_wait_for_fences() vkms_atomic_commit_tail(s1) ... vkms_crtc_atomic_flush() vkms_plane_colorops_update() cs1->bypass <-- use-after-free drm_property_blob_get(cs1->data) For a nonblocking commit, drm_atomic_helper_swap_state() publishes commit 1's new_colorop_state into colorop->state and drops the modeset locks before commit_work runs vkms_atomic_commit_tail(). If commit 1 is still waiting (for example in drm_atomic_helper_wait_for_fences() on an IN_FENCE_FD) when commit 2 writes the same value the colorop property already has, drm_atomic_set_property() adds the colorop to commit 2 without adding its plane or CRTC. Because drm_colorop_state has no drm_crtc_commit dependency tracking, commit 2 swaps and frees commit 1's new_colorop_state immediately, before commit 1 reaches vkms_crtc_atomic_flush(). Capturing colorop_states during atomic_check before drm_atomic_helper_swap_state(), while plane->mutex is still held, would avoid this race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128-colorop-v1= -0-dd79919f822b@gmail.com?part=3D3