From: sashiko-bot@kernel.org
To: "Tarel Ethridge" <tarelerulz@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/v3d: Propagate a failed job's error to dependent jobs
Date: Sun, 22 Nov 2026 17:29:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-228145@kernel.org> (raw)
In-Reply-To: <20261121035551.8048-1-tarelerulz@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/v3d: unbounded user in_sync_count passed to kcalloc() in
v3d_job_add_syncobj_dep()
- [Medium] drm/v3d: duplicate unlocked syncobj lookup and TOCTOU race in
v3d_job_add_syncobj_dep()
--
commit 306a08e6c3987e679232c1d45332551d2561d4dd
Author: Tarel Ethridge <tarelerulz@gmail.com>
drm/v3d: Propagate a failed job's error to dependent jobs
This commit records a job's syncobj dependency fences and the previous
job's done_fence on struct v3d_job so that run_job() callbacks can
propagate any error from those fences to the job's finished fence.
> diff --git a/drivers/gpu/drm/v3d/v3d_submit.c b/drivers/gpu/drm/v3d/v3d_submit.c
> index eada30a317015..3f464128cf4b5 100644
> --- a/drivers/gpu/drm/v3d/v3d_submit.c
> +++ b/drivers/gpu/drm/v3d_submit.c
[ ... ]
> @@ -203,6 +207,34 @@ void v3d_job_put(struct v3d_job *job)
> kref_put(&job->refcount, job->free);
> }
>
> +/* Remember the fence a syncobj dependency waits on, so that run_job() can
> + * tell whether the work this job depends on failed.
> + */
> +static int
> +v3d_job_add_syncobj_dep(struct v3d_job *job, struct drm_file *file_priv,
> + u32 handle, u32 max_deps)
> +{
> + struct dma_fence *fence = NULL;
> + int ret;
> +
> + ret = drm_sched_job_add_syncobj_dependency(&job->base, file_priv, handle, 0);
> + if (ret)
> + return ret;
> +
> + if (!job->dep_fences) {
> + job->dep_fences = kcalloc(max_deps, sizeof(*job->dep_fences),
> + GFP_KERNEL);
> + if (!job->dep_fences)
> + return -ENOMEM;
> + }
> +
> + if (job->dep_count < max_deps &&
> + !drm_syncobj_find_fence(file_priv, handle, 0, 0, &fence) && fence)
> + job->dep_fences[job->dep_count++] = fence;
[Severity: Medium]
Can the second drm_syncobj_find_fence() lookup observe a different fence
than the one drm_sched_job_add_syncobj_dependency() just added?
drm_sched_job_add_syncobj_dependency() resolves handle via
drm_syncobj_find_fence() and releases the syncobj locks before
v3d_job_add_syncobj_dep() looks up handle a second time. If another
thread or an in-flight CPU query job replaces or resets the syncobj fence
in between, job->dep_fences records a different fence (or none at all)
than job->base.dependencies, so v3d_job_failed() either misses the error
from the fence the scheduler waited on or checks an unrelated newer fence.
Looking up the fence once with drm_syncobj_find_fence(), saving an extra
reference with dma_fence_get() in job->dep_fences, and passing the fence
to drm_sched_job_add_dependency() would avoid both the race and the
duplicate lookup.
> +
> + return 0;
> +}
> +
> static int
> v3d_job_add_syncobjs(struct v3d_job *job, struct drm_file *file_priv,
> u32 in_sync, struct v3d_submit_ext *se)
> @@ -214,8 +246,7 @@ v3d_job_add_syncobjs(struct v3d_job *job, struct drm_file *file_priv,
> if (!has_multisync) {
> /* Ignore syncobj if its handle is zero */
> if (in_sync)
> - ret = drm_sched_job_add_syncobj_dependency(&job->base, file_priv,
> - in_sync, 0);
> + ret = v3d_job_add_syncobj_dep(job, file_priv, in_sync, 1);
> return ret;
> }
>
> @@ -232,8 +263,8 @@ v3d_job_add_syncobjs(struct v3d_job *job, struct drm_file *file_priv,
>
> /* Ignore syncobj if its handle is zero */
> if (in.handle) {
> - ret = drm_sched_job_add_syncobj_dependency(&job->base,
> - file_priv, in.handle, 0);
> + ret = v3d_job_add_syncobj_dep(job, file_priv, in.handle,
> + se->in_sync_count);
[Severity: Medium]
Can passing the unvalidated se->in_sync_count as max_deps to kcalloc()
trigger a page allocator warning or high-order allocation stall from
userspace?
v3d_get_multisync_submit_deps() copies multisync.in_sync_count directly
from userspace without bounds checking. On the first valid non-zero
in.handle, v3d_job_add_syncobj_dep() allocates job->dep_fences for the
entire se->in_sync_count via kcalloc(..., GFP_KERNEL) before the rest of
the user array is copied, so a single valid handle with a large
in_sync_count triggers WARN_ON_ONCE_GFP(size > KMALLOC_MAX_SIZE, flags)
in the slab allocator.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121035551.8048-1-tarelerulz@gmail.com?part=1
prev parent reply other threads:[~2026-11-22 17:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 3:55 [PATCH] drm/v3d: Propagate a failed job's error to dependent jobs Tarel Ethridge
2026-11-21 11:56 ` Maíra Canal
2026-11-21 15:09 ` Maíra Canal
2026-11-22 17:29 ` 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=sashiko-outbox-228145@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tarelerulz@gmail.com \
/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.