From: Aravind Thokala <aravind.thokala@amd.com>
To: sashiko-reviews@lists.linux.dev
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH 2/2] fpga: versal: add dma-buf programming support
Date: Thu, 20 Aug 2026 12:27:57 +0530 [thread overview]
Message-ID: <c13b66fa-b3e7-4ac9-a889-36c924049b5f@amd.com> (raw)
In-Reply-To: <20260816151831.E3C241F000E9@smtp.kernel.org>
Hi,
On 8/16/2026 8:48 PM, sashiko-bot@kernel.org wrote:
> [You don't often get email from sashiko-bot@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Passing a user-accessible dma-buf directly to the PMC firmware introduces a speculative Time-of-Check to Time-of-Use (TOCTOU) vulnerability that can potentially bypass FPGA bitstream authentication.
> --
>
> --- Patch [2]: [PATCH 2/2] fpga: versal: add dma-buf programming support ---
> commit 92384704c37fbbfe16cd9659151fbb8646c178cc
> Author: Aravind Thokala <aravind.thokala@amd.com>
>
> fpga: versal: add dma-buf programming support
>
> This commit adds a .write_sg callback to the Versal FPGA driver to support
> dma-buf based programming. It extracts the DMA address from the scatter-gather
> table and passes it directly to the firmware, avoiding an intermediate buffer
> copy.
>
>> diff --git a/drivers/fpga/versal-fpga.c b/drivers/fpga/versal-fpga.c
>> index e6189106c4686..bdaa15a6c9913 100644
>> --- a/drivers/fpga/versal-fpga.c
>> +++ b/drivers/fpga/versal-fpga.c
>
> [ ... ]
>
>> @@ -37,11 +38,34 @@ static int versal_fpga_ops_write(struct fpga_manager *mgr,
>> return ret;
>> }
>>
>> +static int versal_fpga_ops_write_sg(struct fpga_manager *mgr,
>> + struct sg_table *sgt)
>> +{
>> + dma_addr_t dma_addr;
>> +
>> + /* zynqmp_pm_load_pdi() takes a single base address */
>> + if (sgt->nents != 1) {
>> + dev_err(&mgr->dev, "dma-buf has %u segments, need exactly 1\n",
>> + sgt->nents);
>> + return -EINVAL;
>> + }
>> +
>> + dma_addr = sg_dma_address(sgt->sgl);
>> +
>> + return zynqmp_pm_load_pdi(PDI_SRC_DDR, dma_addr);
>
> [Severity: Medium]
> Does this expose the firmware to a Time-of-Check to Time-of-Use (TOCTOU)
> vulnerability if the Xilinx PMC firmware double-fetches the payload?
>
> By extracting the DMA address from the user-provided dma-buf and passing
> it directly to zynqmp_pm_load_pdi() without copying it to a kernel-owned
> isolated buffer, a process could potentially modify the bitstream
> concurrently during the firmware's authentication and loading process.
>
> If a user with CAP_SYS_RAWIO maintains a writable memory mapping to the
> dma-buf (for instance, using udmabuf) and invokes FPGA_IOCTL_LOAD_DMA_BUF,
> they could overwrite the memory while the firmware reads it.
>
> If the firmware re-reads any part of the bitstream after authentication,
> could this be abused to bypass secure boot boundaries?
>
>> +}
>> +
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260816150734.2092802-1-aravind.thokala@amd.com?part=2
This patch series provides a zero-copy path for FPGA programming by
passing a userspace-allocated DMA buffer directly to the firmware.
Secure bitstream authentication is outside the scope of this series.
It is handled entirely by the firmware.
This follows the same approach as the existing write callback, which
also provides a DMA address to zynqmp_pm_load_pdi().
The dma-buf path does not alter the existing security model.
Kind Regards,
Aravind.
next prev parent reply other threads:[~2026-08-20 6:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 15:07 [PATCH 0/2] fpga: add dma-buf based FPGA programming interface Aravind Thokala
2026-08-16 15:07 ` [PATCH 1/2] fpga: Add dma-buf interface for FPGA programming Aravind Thokala
2026-08-16 15:19 ` sashiko-bot
2026-08-16 15:07 ` [PATCH 2/2] fpga: versal: add dma-buf programming support Aravind Thokala
2026-08-16 15:18 ` sashiko-bot
2026-08-20 6:57 ` Aravind Thokala [this message]
2026-08-24 8:50 ` [PATCH 0/2] fpga: add dma-buf based FPGA programming interface 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=c13b66fa-b3e7-4ac9-a889-36c924049b5f@amd.com \
--to=aravind.thokala@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.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.