From: sashiko-bot@kernel.org
To: "Baineng Shou" <shoubaineng@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] dma-fence: Fix dma_fence_timeline_name() to call get_timeline_name()
Date: Thu, 25 Jun 2026 14:27:42 +0000 [thread overview]
Message-ID: <20260625142742.C80771F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260625141227.38931-1-shoubaineng@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Potential NULL pointer dereference in `dma_fence_timeline_name()` and `dma_fence_driver_name()` due to a missing `ops` NULL check when the fence is concurrently signaled without a read memory barrier.
--
commit 118120d707b8593d71c08a5c22b1149fdc6d4229
Author: Baineng Shou <shoubaineng@gmail.com>
dma-fence: Fix dma_fence_timeline_name() to call get_timeline_name()
This patch fixes a copy-paste error where dma_fence_timeline_name()
incorrectly invoked get_driver_name() instead of get_timeline_name().
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index b3bfa6943a8e1..5292d714419b1 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -1202,7 +1202,7 @@ const char __rcu *dma_fence_timeline_name(struct dma_fence *fence)
> /* RCU protection is required for safe access to returned string */
> ops = rcu_dereference(fence->ops);
> if (!dma_fence_test_signaled_flag(fence))
> - return (const char __rcu *)ops->get_driver_name(fence);
> + return (const char __rcu *)ops->get_timeline_name(fence);
[Severity: Critical]
This is a pre-existing issue, but is it possible for ops to be NULL here
due to memory reordering?
If dma_fence_signal_timestamp_locked() runs concurrently, it sets
DMA_FENCE_FLAG_SIGNALED_BIT (which includes a full memory barrier via
test_and_set_bit()) and then sets fence->ops = NULL via RCU_INIT_POINTER().
Since rcu_dereference() and test_bit() inside dma_fence_test_signaled_flag()
are independent memory loads without an intervening read memory barrier,
could a reader on weakly-ordered architectures experience reordering?
Reader CPU:
1. Loads fence->flags -> 0 (sees not signaled)
2. Loads fence->ops -> NULL (sees new value)
3. !dma_fence_test_signaled_flag(fence) evaluates to true
4. ops->get_timeline_name(fence) dereferences NULL
Would adding a NULL check for ops, or an smp_rmb() between the reads,
be necessary to prevent a potential kernel panic if this is reachable via
concurrent ioctls like SYNC_IOC_FILE_INFO?
Does dma_fence_driver_name() also share this same structural vulnerability
when dereferencing ops->get_driver_name?
> else
> return (const char __rcu *)"signaled-timeline";
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260625141227.38931-1-shoubaineng@gmail.com?part=1
next prev parent reply other threads:[~2026-06-25 14:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 14:12 [PATCH] dma-fence: Fix dma_fence_timeline_name() to call get_timeline_name() Baineng Shou
2026-06-25 14:27 ` sashiko-bot [this message]
2026-06-25 15:01 ` Philipp Stanner
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=20260625142742.C80771F000E9@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.