From: sashiko-bot@kernel.org
To: "Baineng Shou" <shoubaineng@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] dma-fence: Make dma_fence_dedup_array() robust against 0-count input
Date: Mon, 29 Jun 2026 03:23:42 +0000 [thread overview]
Message-ID: <20260629032343.0EEDD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260629031346.3875683-1-shoubaineng@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The commit message incorrectly claims that all in-tree callers pre-filter the `num_fences == 0` case. In reality, `amdgpu_userq_wait_return_fence_info()` can and does pass 0, meaning this patch actually fixes a critical pre-existing use-of-uninitialized-memory vulnerability.
--
commit a22db32a014bd90abd28aebf26a5fc39ddb4a3cc
Author: Baineng Shou <shoubaineng@gmail.com>
dma-fence: Make dma_fence_dedup_array() robust against 0-count input
This commit updates dma_fence_dedup_array() to handle an input of 0 fences
by returning 0 early. It also explains how the previous implementation
incorrectly returned 1, which could lead to dereferencing uninitialized
fence slots in arrays.
> All in-tree callers currently filter num_fences == 0 before invoking
> this helper (__dma_fence_unwrap_merge() bails out via the
> `if (count == 0 || count == 1)` fast path; amdgpu_userq_wait_*()
> cannot reach the dedup call with a zero local count because the
> amdgpu_userq_wait_add_fence() helper guarantees num_fences stays in
> [0, wait_info->num_fences], and wait_info->num_fences > 0 is enforced
> at the ioctl entry).
[Severity: Critical]
This is a pre-existing issue, but the commit message claims that all
in-tree callers pre-filter the num_fences == 0 case. Is this description
accurate?
Looking at amdgpu_userq_wait_return_fence_info() in
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c, if a user calls the ioctl
with wait_info->num_fences > 0 but with no actual handles, the local
num_fences variable will remain 0.
Prior to this patch, dma_fence_dedup_array(fences, 0) returned 1:
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c:amdgpu_userq_wait_return_fence_info() {
...
num_fences = dma_fence_dedup_array(fences, num_fences);
...
}
This causes the subsequent loop to read fences[0], which contains
uninitialized kernel heap data from kmalloc_array(), and pass it to
dma_fence_wait():
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c:amdgpu_userq_wait_return_fence_info() {
...
for (i = 0, cnt = 0; i < num_fences; i++) {
...
r = dma_fence_wait(fences[i], true);
...
}
Does this mean this patch actually fixes a pre-existing
use-of-uninitialized-memory regression that could lead to arbitrary code
execution?
If so, should this commit message be updated to reflect it is a security
fix and include a Cc: stable tag for backporting?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260629031346.3875683-1-shoubaineng@gmail.com?part=1
next prev parent reply other threads:[~2026-06-29 3:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 3:13 [PATCH] dma-fence: Make dma_fence_dedup_array() robust against 0-count input Baineng Shou
2026-06-29 3:23 ` sashiko-bot [this message]
2026-06-29 6:59 ` Philipp Stanner
2026-06-29 8:45 ` Christian König
2026-06-29 8:49 ` Philipp Stanner
2026-06-29 8:52 ` Christian König
2026-06-29 9:06 ` Philipp Stanner
2026-06-29 9:52 ` Christian König
2026-06-29 10:16 ` Philipp Stanner
2026-06-29 11:51 ` Christian König
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=20260629032343.0EEDD1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shoubaineng@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.