* FAILED: patch "[PATCH] drm/v3d: Release indirect CSD GEM reference on CPU job free" failed to apply to 6.12-stable tree
@ 2026-05-28 13:35 gregkh
2026-06-01 13:17 ` [PATCH 6.12.y 1/3] drm/v3d: Synchronous operations can't timeout Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-05-28 13:35 UTC (permalink / raw)
To: mcanal, itoral; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 6eb6e5acafa46854d4363e6c34981289995f3ace
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026052815-arose-kabob-9b34@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6eb6e5acafa46854d4363e6c34981289995f3ace Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ADra=20Canal?= <mcanal@igalia.com>
Date: Fri, 15 May 2026 12:07:15 -0300
Subject: [PATCH] drm/v3d: Release indirect CSD GEM reference on CPU job free
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
v3d_get_cpu_indirect_csd_params() takes a reference to the indirect BO via
drm_gem_object_lookup() and stashes it in cpu_job->indirect_csd.indirect,
but nothing on the CPU job teardown path ever drops that reference.
Drop the extra reference in v3d_cpu_job_free(). The NULL check covers ioctl
errors before the lookup ran and CPU job types other than
V3D_CPU_JOB_TYPE_INDIRECT_CSD, which leave the field zero-initialised.
Cc: stable@vger.kernel.org
Fixes: 18b8413b25b7 ("drm/v3d: Create a CPU job extension for a indirect CSD job")
Assisted-by: Claude:claude-opus-4.7
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20260515-v3d-cpu-job-leaks-v1-2-7f147cbbf935@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
index e3a6e7cc7bd5..3ddd53b6f437 100644
--- a/drivers/gpu/drm/v3d/v3d_submit.c
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
@@ -135,6 +135,9 @@ v3d_cpu_job_free(struct kref *ref)
v3d_performance_query_info_free(&job->performance_query,
job->performance_query.count);
+ if (job->indirect_csd.indirect)
+ drm_gem_object_put(job->indirect_csd.indirect);
+
v3d_job_free(ref);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 6.12.y 1/3] drm/v3d: Synchronous operations can't timeout 2026-05-28 13:35 FAILED: patch "[PATCH] drm/v3d: Release indirect CSD GEM reference on CPU job free" failed to apply to 6.12-stable tree gregkh @ 2026-06-01 13:17 ` Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 2/3] drm/v3d: Fix use-after-free of CPU job query arrays on error path Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 3/3] drm/v3d: Release indirect CSD GEM reference on CPU job free Sasha Levin 0 siblings, 2 replies; 4+ messages in thread From: Sasha Levin @ 2026-06-01 13:17 UTC (permalink / raw) To: stable; +Cc: Maíra Canal, Iago Toral Quiroga, Melissa Wen, Sasha Levin From: Maíra Canal <mcanal@igalia.com> [ Upstream commit 78fe02d090d38393cc00de9d1929e59426f202a4 ] CPU jobs and CACHE CLEAN jobs execute synchronously once the DRM scheduler starts running them. Therefore, there is no fence to wait on, neither are those jobs able to timeout. Hence, remove the `timedout_job` hook from the CPU and CACHE CLEAN scheduler ops. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Melissa Wen <mwen@igalia.com> Link: https://lore.kernel.org/r/20250826-v3d-queue-lock-v3-5-979efc43e490@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com> Stable-dep-of: 6eb6e5acafa4 ("drm/v3d: Release indirect CSD GEM reference on CPU job free") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/gpu/drm/v3d/v3d_sched.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index c9c88d3ad6698..63564266135f6 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c @@ -684,6 +684,7 @@ v3d_cpu_job_run(struct drm_sched_job *sched_job) trace_v3d_cpu_job_end(&v3d->drm, job->job_type); v3d_job_update_stats(&job->base, V3D_CPU); + /* Synchronous operation, so no fence to wait on. */ return NULL; } @@ -699,6 +700,7 @@ v3d_cache_clean_job_run(struct drm_sched_job *sched_job) v3d_job_update_stats(job, V3D_CACHE_CLEAN); + /* Synchronous operation, so no fence to wait on. */ return NULL; } @@ -786,7 +788,7 @@ v3d_render_job_timedout(struct drm_sched_job *sched_job) } static enum drm_gpu_sched_stat -v3d_generic_job_timedout(struct drm_sched_job *sched_job) +v3d_tfu_job_timedout(struct drm_sched_job *sched_job) { struct v3d_job *job = to_v3d_job(sched_job); @@ -827,7 +829,7 @@ static const struct drm_sched_backend_ops v3d_render_sched_ops = { static const struct drm_sched_backend_ops v3d_tfu_sched_ops = { .run_job = v3d_tfu_job_run, - .timedout_job = v3d_generic_job_timedout, + .timedout_job = v3d_tfu_job_timedout, .free_job = v3d_sched_job_free, }; @@ -839,13 +841,11 @@ static const struct drm_sched_backend_ops v3d_csd_sched_ops = { static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { .run_job = v3d_cache_clean_job_run, - .timedout_job = v3d_generic_job_timedout, .free_job = v3d_sched_job_free }; static const struct drm_sched_backend_ops v3d_cpu_sched_ops = { .run_job = v3d_cpu_job_run, - .timedout_job = v3d_generic_job_timedout, .free_job = v3d_cpu_job_free }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.12.y 2/3] drm/v3d: Fix use-after-free of CPU job query arrays on error path 2026-06-01 13:17 ` [PATCH 6.12.y 1/3] drm/v3d: Synchronous operations can't timeout Sasha Levin @ 2026-06-01 13:17 ` Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 3/3] drm/v3d: Release indirect CSD GEM reference on CPU job free Sasha Levin 1 sibling, 0 replies; 4+ messages in thread From: Sasha Levin @ 2026-06-01 13:17 UTC (permalink / raw) To: stable; +Cc: Maíra Canal, Iago Toral Quiroga, Sasha Levin From: Maíra Canal <mcanal@igalia.com> [ Upstream commit b0fe80c0b9250b35e2211bf3117e7aca814a21b0 ] The CPU job ioctl's fail label calls kvfree() on cpu_job's timestamp and performance query arrays after v3d_job_cleanup(), which drops the job's last reference and frees cpu_job. Reading cpu_job at that point is a use-after-free. Also, on the early v3d_job_init() failure path, it is a NULL dereference, since v3d_job_deallocate() zeroes the local pointer. In the success path, the arrays are released from the scheduler's .free_job callback, but on the error path, they are freed manually, as the job was never pushed to the scheduler. While the success path deals with this correctly, the fail path doesn't. On top of that, the manual kvfree() calls only free the array storage; they don't drm_syncobj_put() the per-query syncobjs that v3d_timestamp_query_info_free() and v3d_performance_query_info_free() release on the success path. So the same fail path that triggers the use-after-free also leaks one syncobj reference per query. Unify the CPU job teardown into the CPU job's kref destructor, mirroring v3d_render_job_free(). The scheduler's .free_job slot reverts to the generic v3d_sched_job_free() and the fail label drops the manual kvfree() calls, leaving a single teardown path that is reached from both the scheduler and the ioctl error path. That removes the use-after-free, the NULL dereference, and the syncobj leak by construction. Cc: stable@vger.kernel.org Fixes: 9ba0ff3e083f ("drm/v3d: Create a CPU job extension for the timestamp query job") Assisted-by: Claude:claude-opus-4.7 Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Link: https://patch.msgid.link/20260515-v3d-cpu-job-leaks-v1-1-7f147cbbf935@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com> Stable-dep-of: 6eb6e5acafa4 ("drm/v3d: Release indirect CSD GEM reference on CPU job free") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/gpu/drm/v3d/v3d_sched.c | 16 +--------------- drivers/gpu/drm/v3d/v3d_submit.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/v3d/v3d_sched.c b/drivers/gpu/drm/v3d/v3d_sched.c index 63564266135f6..c5b63ba46f3db 100644 --- a/drivers/gpu/drm/v3d/v3d_sched.c +++ b/drivers/gpu/drm/v3d/v3d_sched.c @@ -103,20 +103,6 @@ v3d_performance_query_info_free(struct v3d_performance_query_info *query_info, } } -static void -v3d_cpu_job_free(struct drm_sched_job *sched_job) -{ - struct v3d_cpu_job *job = to_cpu_job(sched_job); - - v3d_timestamp_query_info_free(&job->timestamp_query, - job->timestamp_query.count); - - v3d_performance_query_info_free(&job->performance_query, - job->performance_query.count); - - v3d_job_cleanup(&job->base); -} - static void v3d_switch_perfmon(struct v3d_dev *v3d, struct v3d_job *job) { @@ -846,7 +832,7 @@ static const struct drm_sched_backend_ops v3d_cache_clean_sched_ops = { static const struct drm_sched_backend_ops v3d_cpu_sched_ops = { .run_job = v3d_cpu_job_run, - .free_job = v3d_cpu_job_free + .free_job = v3d_sched_job_free }; int diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c index ddc20191a1cee..40c21aaade0d6 100644 --- a/drivers/gpu/drm/v3d/v3d_submit.c +++ b/drivers/gpu/drm/v3d/v3d_submit.c @@ -118,6 +118,21 @@ v3d_render_job_free(struct kref *ref) v3d_job_free(ref); } +static void +v3d_cpu_job_free(struct kref *ref) +{ + struct v3d_cpu_job *job = container_of(ref, struct v3d_cpu_job, + base.refcount); + + v3d_timestamp_query_info_free(&job->timestamp_query, + job->timestamp_query.count); + + v3d_performance_query_info_free(&job->performance_query, + job->performance_query.count); + + v3d_job_free(ref); +} + void v3d_job_cleanup(struct v3d_job *job) { if (!job) @@ -1310,7 +1325,7 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data, trace_v3d_submit_cpu_ioctl(&v3d->drm, cpu_job->job_type); ret = v3d_job_init(v3d, file_priv, &cpu_job->base, - v3d_job_free, 0, &se, V3D_CPU); + v3d_cpu_job_free, 0, &se, V3D_CPU); if (ret) { v3d_job_deallocate((void *)&cpu_job); goto fail; @@ -1393,8 +1408,6 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data, v3d_job_cleanup((void *)csd_job); v3d_job_cleanup(clean_job); v3d_put_multisync_post_deps(&se); - kvfree(cpu_job->timestamp_query.queries); - kvfree(cpu_job->performance_query.queries); return ret; } -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.12.y 3/3] drm/v3d: Release indirect CSD GEM reference on CPU job free 2026-06-01 13:17 ` [PATCH 6.12.y 1/3] drm/v3d: Synchronous operations can't timeout Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 2/3] drm/v3d: Fix use-after-free of CPU job query arrays on error path Sasha Levin @ 2026-06-01 13:17 ` Sasha Levin 1 sibling, 0 replies; 4+ messages in thread From: Sasha Levin @ 2026-06-01 13:17 UTC (permalink / raw) To: stable; +Cc: Maíra Canal, Iago Toral Quiroga, Sasha Levin From: Maíra Canal <mcanal@igalia.com> [ Upstream commit 6eb6e5acafa46854d4363e6c34981289995f3ace ] v3d_get_cpu_indirect_csd_params() takes a reference to the indirect BO via drm_gem_object_lookup() and stashes it in cpu_job->indirect_csd.indirect, but nothing on the CPU job teardown path ever drops that reference. Drop the extra reference in v3d_cpu_job_free(). The NULL check covers ioctl errors before the lookup ran and CPU job types other than V3D_CPU_JOB_TYPE_INDIRECT_CSD, which leave the field zero-initialised. Cc: stable@vger.kernel.org Fixes: 18b8413b25b7 ("drm/v3d: Create a CPU job extension for a indirect CSD job") Assisted-by: Claude:claude-opus-4.7 Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Link: https://patch.msgid.link/20260515-v3d-cpu-job-leaks-v1-2-7f147cbbf935@igalia.com Signed-off-by: Maíra Canal <mcanal@igalia.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/gpu/drm/v3d/v3d_submit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c index 40c21aaade0d6..23472c7af41a9 100644 --- a/drivers/gpu/drm/v3d/v3d_submit.c +++ b/drivers/gpu/drm/v3d/v3d_submit.c @@ -130,6 +130,9 @@ v3d_cpu_job_free(struct kref *ref) v3d_performance_query_info_free(&job->performance_query, job->performance_query.count); + if (job->indirect_csd.indirect) + drm_gem_object_put(job->indirect_csd.indirect); + v3d_job_free(ref); } -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-01 13:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-28 13:35 FAILED: patch "[PATCH] drm/v3d: Release indirect CSD GEM reference on CPU job free" failed to apply to 6.12-stable tree gregkh 2026-06-01 13:17 ` [PATCH 6.12.y 1/3] drm/v3d: Synchronous operations can't timeout Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 2/3] drm/v3d: Fix use-after-free of CPU job query arrays on error path Sasha Levin 2026-06-01 13:17 ` [PATCH 6.12.y 3/3] drm/v3d: Release indirect CSD GEM reference on CPU job free Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox