From: Steven Rostedt <rostedt@goodmis.org>
To: Martin Kaiser <martin@kaiser.cx>
Cc: Frank Li <Frank.Li@nxp.com>, Vinod Koul <vkoul@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
imx@lists.linux.dev, dmaengine@vger.kernel.org
Subject: Re: [PATCH] fsl-edma: tracing: no ptr dereference during log output
Date: Tue, 30 Jun 2026 16:05:44 -0400 [thread overview]
Message-ID: <20260630160544.4211ae88@gandalf.local.home> (raw)
In-Reply-To: <20260630200022.1826420-1-martin@kaiser.cx>
On Tue, 30 Jun 2026 22:00:11 +0200
Martin Kaiser <martin@kaiser.cx> wrote:
> The fsl edma events store a pointer to a struct fsl_edma_engine in the
> ringbuffer and dereference it when a log entry is printed. At this time,
> the pointer may no longer be valid.
Nice catch.
>
> Event injection can be used to trigger a crash:
>
> $ cd /sys/kernel/tracing
> $ echo 'value = 0' > events/fsl_edma/edma_writeb/inject
> $ cat trace
>
> The log output needs only edma->membase. Add a membase field at the end
> of the event and use the new field for log output. Keep the existing
> fields for backward compatibility.
>
Cc: stable@vger.kernel.org
> Fixes: 11102d0c343b ("dmaengine: fsl-edma: add trace event support")
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> drivers/dma/fsl-edma-trace.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/fsl-edma-trace.h b/drivers/dma/fsl-edma-trace.h
> index d3541301a247..45d964a3726d 100644
> --- a/drivers/dma/fsl-edma-trace.h
> +++ b/drivers/dma/fsl-edma-trace.h
> @@ -19,14 +19,16 @@ DECLARE_EVENT_CLASS(edma_log_io,
> __field(struct fsl_edma_engine *, edma)
> __field(void __iomem *, addr)
> __field(u32, value)
> + __field(void __iomem *, membase)
> ),
> TP_fast_assign(
> __entry->edma = edma;
> __entry->addr = addr;
> __entry->value = value;
> + __entry->membase = edma->membase;
> ),
> TP_printk("offset %08x: value %08x",
> - (u32)(__entry->addr - __entry->edma->membase), __entry->value)
> + (u32)(__entry->addr - __entry->membase), __entry->value)
Hmm, I think I should update the TP_printk checks at boot to cover this too.
-- Steve
> );
>
> DEFINE_EVENT(edma_log_io, edma_readl,
next prev parent reply other threads:[~2026-06-30 20:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 20:00 [PATCH] fsl-edma: tracing: no ptr dereference during log output Martin Kaiser
2026-06-30 20:05 ` Steven Rostedt [this message]
2026-06-30 20:44 ` Steven Rostedt
2026-06-30 20:36 ` Frank Li
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=20260630160544.4211ae88@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=Frank.Li@nxp.com \
--cc=dmaengine@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin@kaiser.cx \
--cc=mhiramat@kernel.org \
--cc=vkoul@kernel.org \
/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