From: Philipp Stanner <phasta@mailbox.org>
To: christian.koenig@amd.com, malhyuk97@gmail.com,
tursulin@ursulin.net, matthew.brost@intel.com, dakr@kernel.org
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
mdaenzer@redhat.com, alessio.belle@imgtec.com,
luigi.santivetti@imgtec.com
Subject: Re: [PATCH 1/2] dma-buf/dma-fence: fix checking signaling bit for timeline and driver name
Date: Wed, 09 Sep 2026 15:58:23 +0200 [thread overview]
Message-ID: <378b2599ada8e62cd772dfc6a751e3e39cfad04a.camel@mailbox.org> (raw)
In-Reply-To: <20260909131808.2201-2-christian.koenig@amd.com>
On Wed, 2026-09-09 at 15:14 +0200, Christian König wrote:
> The patch "dma-buf: dma-fence: Fix potential NULL pointer dereference"
> changed the check to test for the ops pointer instead of the signaled
> bit to avoid a potential NULL dereference when the ops pointer has been
> cleared.
>
> The problem is now that the ops pointer is cleared only when neither the
> release nor the wait callback is implemented and this isn't true for a lot
> of dma_fence implementations yet. So those implementations lost the RCU
> protection after signaling of the returned string resulting in potential
> use after free.
>
> Add the signaling check additional to the ops pointer check so that we
> have both the protection against NULL dereference as well as the RCU
> protection after signaling for the returned string.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Fixes: 035219a760ed ("dma-buf: dma-fence: Fix potential NULL pointer dereference")
> CC: stable@vger.kernel.org # 7.2+
> Reported-by: Jonghyuk Kim(MalHyuk) <malhyuk97@gmail.com>
> Tested-by: Jonghyuk Kim(MalHyuk) <malhyuk97@gmail.com>
> ---
> drivers/dma-buf/dma-fence.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 05090fb0fd5a..e92f9df8d63c 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -1170,7 +1170,7 @@ const char __rcu *dma_fence_driver_name(struct dma_fence *fence)
>
> /* RCU protection is required for safe access to returned string */
> ops = rcu_dereference(fence->ops);
> - if (ops)
> + if (!dma_fence_test_signaled_flag(fence) && ops)
It's probably a good idea to comment at an appropriate place (I suggest
here and at dma_fence_ops) why this is necessary, because at all other
places the ops-pointer can serve as decoupling point.
Reason is simply to also support drivers that implement release() and
wait(), preventing ops from being set to NULL.
P.
next prev parent reply other threads:[~2026-09-09 13:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 13:14 Fix dma_fence use after free regression Christian König
2026-09-09 13:14 ` [PATCH 1/2] dma-buf/dma-fence: fix checking signaling bit for timeline and driver name Christian König
2026-09-09 13:58 ` Philipp Stanner [this message]
2026-09-09 13:14 ` [PATCH 2/2] drm/sched: document the RCU dependency Christian König
2026-09-09 13:55 ` Philipp Stanner
2026-09-09 13:57 ` 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=378b2599ada8e62cd772dfc6a751e3e39cfad04a.camel@mailbox.org \
--to=phasta@mailbox.org \
--cc=alessio.belle@imgtec.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luigi.santivetti@imgtec.com \
--cc=malhyuk97@gmail.com \
--cc=matthew.brost@intel.com \
--cc=mdaenzer@redhat.com \
--cc=phasta@kernel.org \
--cc=tursulin@ursulin.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®