All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Philipp Stanner" <phasta@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] dma-buf/dma-fence: Set better string for dma_fence_driver_name()
Date: Tue, 23 Jun 2026 15:48:07 +0000	[thread overview]
Message-ID: <20260623154807.C0A6C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260623133457.1029880-2-phasta@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Critical] ABI breakage in UAPI `sync_fence_info` and severe string truncation.

Pre-existing issues:
- [Critical] Potential NULL pointer dereference due to unordered reads of `fence->ops` and `fence->flags`.
--

commit 2d4e0eac87d76c56e73514e9ac37b9db142b0e4f
Author: Philipp Stanner <phasta@kernel.org>

dma-buf/dma-fence: Set better string for dma_fence_driver_name()

Rename the "detached-driver" string returned by dma_fence_driver_name()
to something more descriptive for signaled fences.

> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index b3bfa6943a8e1..4a326d2ba7d19 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -1171,7 +1171,7 @@ const char __rcu *dma_fence_driver_name(struct dma_fence *fence)
>  	if (!dma_fence_test_signaled_flag(fence))
>  		return (const char __rcu *)ops->get_driver_name(fence);

[Severity: Critical]
This is a pre-existing issue, but could this cause a NULL pointer dereference?

In dma_fence_driver_name(), fence->ops and fence->flags are read
independently without an smp_rmb() memory barrier. If the CPU reads
fence->flags as unsignaled first, and concurrently another CPU signals the
fence, dma_fence_signal_timestamp_locked() can set fence->flags to signaled
and then set fence->ops to NULL (for fences lacking .release and .wait ops,
such as virtgpu_fence or v3d_fence).

The reader CPU might then read fence->ops as NULL, take the if branch (using
the cached flags=0), and crash on ops->get_driver_name(fence).

>  	else
> -		return (const char __rcu *)"detached-driver";
> +		return (const char __rcu *)"driver-whose-fence-is-signaled";

[Severity: Critical]
Does this break the userspace ABI and cause string truncation?

The driver_name field in struct sync_fence_info is exposed to userspace via
the SYNC_IOC_FILE_INFO ioctl. Changing this string from "detached-driver" to
"driver-whose-fence-is-signaled" breaks userspace tools that rely on the
established string to identify decoupled fences.

Also, this formats the UAPI sync_file name into a 32-byte buffer in
sync_file_get_name():

drivers/dma-buf/sync_file.c:sync_file_get_name() {
    ...
	snprintf(buf, len, "%s-%s%llu-%lld",
			 rcu_dereference(driver),
			 rcu_dereference(timeline),
			 fence->context,
			 fence->seqno);
    ...
}

The new 30-character driver name consumes almost the entire 32-byte buffer,
which truncates the timeline name and all subsequent fence metadata.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260623133457.1029880-2-phasta@kernel.org?part=1

      parent reply	other threads:[~2026-06-23 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23 13:34 [PATCH] dma-buf/dma-fence: Set better string for dma_fence_driver_name() Philipp Stanner
2026-06-23 14:00 ` Tvrtko Ursulin
2026-06-23 15:48 ` 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=20260623154807.C0A6C1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=phasta@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.