All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Martin Kaiser" <martin@kaiser.cx>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org,
	imx@lists.linux.dev, vkoul@kernel.org
Subject: Re: [PATCH v2] dmaengine: fsl-edma: tracing: no ptr dereference during log output
Date: Sat, 18 Jul 2026 13:14:53 +0000	[thread overview]
Message-ID: <20260718131453.A94821F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260718130024.341243-1-martin@kaiser.cx>

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

Pre-existing issues:
- [Critical] Double byte-swapping of TCD register values on Big Endian CPUs.
--

--- Patch [1]: [PATCH v2] dmaengine: fsl-edma: tracing: no ptr dereference during log output ---
commit 3052808ada723a8fc5d5327178f31b6879486260
Author: Martin Kaiser <martin@kaiser.cx>
Date:   Sat Jul 18 12:58:48 2026 +0000

    dmaengine: fsl-edma: tracing: no ptr dereference during log output

    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. This adds a
    membase field to the event to avoid dereferencing the pointer, preventing
    a use-after-free if the edma pointer becomes invalid.

    Fixes: 11102d0c343b ("dmaengine: fsl-edma: add trace event support")
    Cc: stable@vger.kernel.org

> diff --git a/drivers/dma/fsl-edma-trace.h b/drivers/dma/fsl-edma-trace.h
> index d3541301a2470..45d964a3726d6 100644
> --- a/drivers/dma/fsl-edma-trace.h
> +++ b/drivers/dma/fsl-edma-trace.h

[ ... ]

>  	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)
>  );

[Severity: Critical]
This is a pre-existing issue, but I noticed a potential problem with how
the value being traced here is written to the hardware on Big Endian CPUs.

When a DMA transfer is initiated, fsl_edma_set_tcd_to_le() prepares the
in-memory descriptor fields in little-endian format. Then
edma_cp_tcd_to_reg() passes this little-endian value to edma_writel() via
edma_write_tcdreg_c():

drivers/dma/fsl-edma-common.h:edma_write_tcdreg_c() {
    ...
    __iomem __le32 : edma_writel(chan->edma, (u32 __force)(_val), ...
    ...
}

However, edma_writel() uses iowrite32() which assumes native CPU-endian
input:

drivers/dma/fsl-edma-common.h:edma_writel() {
    if (edma->big_endian)
        iowrite32be(val, addr);
    else
        iowrite32(val, addr);

    trace_edma_writel(edma, addr, val);
}

On Big Endian CPUs, does this result in iowrite32() double-swapping the
already little-endian descriptor data and writing a corrupted value to the
target and source addresses?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260718130024.341243-1-martin@kaiser.cx?part=1

  reply	other threads:[~2026-07-18 13:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 12:58 [PATCH v2] dmaengine: fsl-edma: tracing: no ptr dereference during log output Martin Kaiser
2026-07-18 13:14 ` sashiko-bot [this message]
2026-07-28  8:19   ` Martin Kaiser
2026-07-28 15:38     ` Frank Li
2026-07-18 14:52 ` 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=20260718131453.A94821F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 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.