All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Leo Yu-Chi Liang" <leo.liang@sifive.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 09/10] gtrace: rvtrace: Add pre-ratified ramsink setup
Date: Thu, 26 Nov 2026 09:19:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-235113@kernel.org> (raw)
In-Reply-To: <20261126-send-preratified-trace-v1-9-1e686fd75be7@sifive.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] gtrace: rvtrace: type confusion and NULL deref in
  rvtrace_v0_ramsink_release()
--

commit 270a89ab261cf1fa742d02dd08528a93ecc64e28
Author: Eric Lin <eric.lin@sifive.com>

gtrace: rvtrace: Add pre-ratified ramsink setup

This commit adds setup and release helpers for the system memory ramsink
embedded in pre-ratified RISC-V trace encoders and funnels, and wires them
into the encoder and funnel probe and remove paths.

> diff --git a/drivers/hwtracing/gtrace/rvtrace-ramsink.c b/drivers/hwtracing/gtrace/rvtrace-ramsink.c
> index a164db57167f8..f183dcd71c7c0 100644
> --- a/drivers/hwtracing/gtrace/rvtrace-ramsink.c
> +++ b/drivers/hwtracing/gtrace/rvtrace-ramsink.c
[ ... ]
> @@ -348,6 +352,104 @@ static void rvtrace_ramsink_cleanup(struct gtrace_component *comp)
>  	dma_free_coherent(comp->pdata->dev, priv->alloc_size, priv->alloc_va, priv->alloc_start);
>  }
>  
> +#ifdef CONFIG_RVTRACE_V0
[ ... ]
> +void rvtrace_v0_ramsink_release(struct gtrace_component *comp,
> +				struct rvtrace_ramsink_priv *priv)
> +{
> +	if (!priv)
> +		return;
> +
> +	rvtrace_ramsink_cleanup(comp);
> +	of_reserved_mem_device_release(comp->pdata->dev);
> +}
> +EXPORT_SYMBOL_GPL(rvtrace_v0_ramsink_release);
> +#endif /* CONFIG_RVTRACE_V0 */

[Severity: High]
Does rvtrace_v0_ramsink_release() pass the wrong private data to
dma_free_coherent() by calling rvtrace_ramsink_cleanup(comp) instead of
using priv?

rvtrace_ramsink_cleanup() retrieves priv via dev_get_drvdata(&comp->dev),
which for a pre-ratified encoder or funnel is struct rvtrace_encoder_priv
or struct rvtrace_funnel_priv rather than the embedded sink's struct
rvtrace_ramsink_priv.  In rvtrace_encoder_remove() and
rvtrace_funnel_remove(), this reads alloc_size, alloc_va and alloc_start
out-of-bounds from the smaller encoder/funnel private struct and leaks the
sink's DMA buffer; on the gtrace_enable_component() failure path in
rvtrace_funnel_probe(), dev_set_drvdata() has not run yet, causing a NULL
pointer dereference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-send-preratified-trace-v1-0-1e686fd75be7@sifive.com?part=9

  reply	other threads:[~2026-11-26  9:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:07 [PATCH 00/10] gtrace: Add support for SiFive pre-ratified RISC-V trace components Leo Yu-Chi Liang
2026-11-26  9:07 ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 01/10] dt-bindings: riscv: Add SiFive pre-ratified " Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 02/10] gtrace: rvtrace: Add pre-ratified implementation callback Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 03/10] gtrace: rvtrace: Add pre-ratified private data callback Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 04/10] gtrace: rvtrace: Add pre-ratified encoder support Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 05/10] gtrace: Terminate id_table iteration on GTRACE_COMPONENT_TYPE_NONE Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 06/10] gtrace: rvtrace: Add pre-ratified trace sink config Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 07/10] gtrace: rvtrace: Add pre-ratified trace funnel driver Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:19   ` sashiko-bot
2026-11-26  9:07 ` [PATCH 08/10] gtrace: rvtrace: Introduce struct rvtrace_ramsink_regs to abstract register offsets Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:07 ` [PATCH 09/10] gtrace: rvtrace: Add pre-ratified ramsink setup Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:19   ` sashiko-bot [this message]
2026-11-26  9:07 ` [PATCH 10/10] gtrace: rvtrace: Add copyto_auxbuf callback for pre-ratified encoder and funnel Leo Yu-Chi Liang
2026-11-26  9:07   ` Leo Yu-Chi Liang
2026-11-26  9:32   ` sashiko-bot

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-235113@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=leo.liang@sifive.com \
    --cc=robh@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.