From: Nathan Lynch <nathan.lynch@amd.com>
To: <sashiko-reviews@lists.linux.dev>
Cc: <vkoul@kernel.org>, <Frank.Li@kernel.org>,
<linux-pci@vger.kernel.org>, <dmaengine@vger.kernel.org>
Subject: Re: [PATCH v2 08/23] dmaengine: sdxi: Install administrative context
Date: Fri, 5 Jun 2026 18:26:42 -0500 [thread overview]
Message-ID: <87pl24d0wd.fsf@amd.com> (raw)
In-Reply-To: <20260513031712.0C8EDC2BCB0@smtp.kernel.org>
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> - [Critical] Hardware Use-After-Free due to missing admin context teardown
> - [High] Torn writes on 32-bit platforms exposing incomplete addresses to hardware
> - [Medium] Incorrect error check for `dma_pool_zalloc()` using the DMA handle instead of the virtual pointer
> --
>
> commit 794d6cb84f7ad6a7699311744a5e9c87b9d20316
> Author: Nathan Lynch <nathan.lynch@amd.com>
>
> dmaengine: sdxi: Install administrative context
>
> This commit serializes the context control block, akey table, and L1 entry for
> the admin context. It makes the descriptor ring, write index, and context
> status block visible to the SDXI implementation once activated.
>
>> diff --git a/drivers/dma/sdxi/context.c b/drivers/dma/sdxi/context.c
>> index 27821cfaf0311..c0b55c945cc4e 100644
>> --- a/drivers/dma/sdxi/context.c
>> +++ b/drivers/dma/sdxi/context.c
>
> [ ... ]
>
>> @@ -106,6 +112,152 @@ static struct sdxi_cxt *sdxi_alloc_cxt(struct sdxi_dev *sdxi)
>
> [ ... ]
>
>> +static int configure_cxt_ctl(struct sdxi_cxt_ctl *ctl, const struct sdxi_cxt_ctl_cfg *cfg)
>> +{
>> + u64 ds_ring_ptr, cxt_sts_ptr, write_index_ptr;
>
> [ ... ]
>
>> + ds_ring_ptr = FIELD_PREP(SDXI_CXT_CTL_VL, 1) |
>> + FIELD_PREP(SDXI_CXT_CTL_QOS, cfg->qos) |
>> + FIELD_PREP(SDXI_CXT_CTL_SE, cfg->se) |
>> + FIELD_PREP(SDXI_CXT_CTL_CSA, cfg->csa) |
>> + FIELD_PREP(SDXI_CXT_CTL_DS_RING_PTR,
>> + cfg->ds_ring_ptr >> DESC_RING_BASE_PTR_SHIFT);
>> + /* Ensure other fields are visible before hw sees vl=1. */
>> + dma_wmb();
>> + WRITE_ONCE(ctl->ds_ring_ptr, cpu_to_le64(ds_ring_ptr));
>
> Can this introduce a regression with torn writes on 32-bit platforms?
As mentioned elsewhere the driver will just depend on CONFIG_64BIT for
now.
>> +static void free_admin_cxt(void *ptr)
>> +{
>> + struct sdxi_dev *sdxi = ptr;
>> +
>> + sdxi_free_cxt(sdxi->admin_cxt);
>> +}
>
> Does this sequence cause a use-after-free regression?
>
> In sdxi_publish_cxt(), the admin context is published to the hardware by
> setting the valid bit (VL=1) in the L1_table.
>
> When the context is torn down via the devres cleanup action free_admin_cxt(),
> it directly invokes sdxi_free_cxt(), which frees the DMA memory for the
> context control block, descriptor ring, and akey table.
>
> However, the VL bit in the hardware's L1 table entry is never cleared. Could
> this leave the hardware actively fetching from freed physical
> addresses?
No I don't think so, the code as written ensures the device is in
stopped state when we get to the point of freeing the admin context
control structures.
> Additionally, looking at the sdxi_alloc_cxt() implementation, the return value
> of dma_pool_zalloc() is checked via the DMA address instead of the virtual
> pointer:
>
> cxt->cxt_ctl = dma_pool_zalloc(sdxi->cxt_ctl_pool, GFP_KERNEL,
> &cxt->cxt_ctl_dma);
> if (!cxt->cxt_ctl_dma)
> return NULL;
>
> Since physical address 0 is a valid DMA address on many architectures and IOMMU
> configurations, could this regression incorrectly abort initialization if a
> successful allocation returns DMA address 0? Should this code check the
> returned virtual pointer (!cxt->cxt_ctl) instead?
Valid bug but I think this is a redundant report, the bot pointed it out
elsewhere in the thread.
next prev parent reply other threads:[~2026-06-05 23:26 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 19:16 [PATCH v2 00/23] dmaengine: Smart Data Accelerator Interface (SDXI) basic support Nathan Lynch via B4 Relay
2026-05-11 19:16 ` [PATCH v2 01/23] PCI: Add SNIA SDXI accelerator sub-class Nathan Lynch via B4 Relay
2026-05-11 20:48 ` Frank Li
2026-05-12 23:50 ` sashiko-bot
2026-05-26 23:44 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 02/23] MAINTAINERS: Add entry for SDXI driver Nathan Lynch via B4 Relay
2026-05-11 19:16 ` [PATCH v2 03/23] dmaengine: sdxi: Add PCI initialization Nathan Lynch via B4 Relay
2026-05-11 21:22 ` Frank Li
2026-05-13 0:05 ` sashiko-bot
2026-05-26 23:28 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 04/23] dmaengine: sdxi: Feature discovery and initial configuration Nathan Lynch via B4 Relay
2026-05-11 21:30 ` Frank Li
2026-05-13 0:33 ` sashiko-bot
2026-06-05 21:25 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 05/23] dmaengine: sdxi: Configure context tables Nathan Lynch via B4 Relay
2026-05-13 1:12 ` sashiko-bot
2026-06-05 22:19 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 06/23] dmaengine: sdxi: Allocate DMA pools Nathan Lynch via B4 Relay
2026-05-13 1:30 ` sashiko-bot
2026-05-27 0:05 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 07/23] dmaengine: sdxi: Allocate administrative context Nathan Lynch via B4 Relay
2026-05-13 2:20 ` sashiko-bot
2026-05-27 0:07 ` Nathan Lynch
2026-05-11 19:16 ` [PATCH v2 08/23] dmaengine: sdxi: Install " Nathan Lynch via B4 Relay
2026-05-13 3:17 ` sashiko-bot
2026-06-05 23:26 ` Nathan Lynch [this message]
2026-05-11 19:16 ` [PATCH v2 09/23] dmaengine: sdxi: Start functions on probe, stop on remove Nathan Lynch via B4 Relay
2026-05-13 3:35 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 10/23] dmaengine: sdxi: Complete administrative context jump start Nathan Lynch via B4 Relay
2026-05-13 3:54 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 11/23] dmaengine: sdxi: Add client context alloc and release APIs Nathan Lynch via B4 Relay
2026-05-13 4:46 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 12/23] dmaengine: sdxi: Add descriptor ring management Nathan Lynch via B4 Relay
2026-05-13 5:21 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 13/23] dmaengine: sdxi: Add unit tests for descriptor ring reservations Nathan Lynch via B4 Relay
2026-05-13 5:48 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 14/23] dmaengine: sdxi: Attach descriptor ring state to contexts Nathan Lynch via B4 Relay
2026-05-13 19:31 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 15/23] dmaengine: sdxi: Per-context access key (AKey) table entry allocator Nathan Lynch via B4 Relay
2026-05-13 19:54 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 16/23] dmaengine: sdxi: Generic descriptor manipulation helpers Nathan Lynch via B4 Relay
2026-05-13 20:21 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 17/23] dmaengine: sdxi: Add completion status block API Nathan Lynch via B4 Relay
2026-05-13 20:38 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 18/23] dmaengine: sdxi: Encode context start, stop, and sync descriptors Nathan Lynch via B4 Relay
2026-05-11 19:16 ` [PATCH v2 19/23] dmaengine: sdxi: Provide context start and stop APIs Nathan Lynch via B4 Relay
2026-05-13 21:18 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 20/23] dmaengine: sdxi: Encode nop, copy, and interrupt descriptors Nathan Lynch via B4 Relay
2026-05-13 21:33 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 21/23] dmaengine: sdxi: Add unit tests for descriptor encoding Nathan Lynch via B4 Relay
2026-05-13 21:55 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 22/23] dmaengine: sdxi: MSI/MSI-X vector allocation and mapping Nathan Lynch via B4 Relay
2026-05-13 22:17 ` sashiko-bot
2026-05-11 19:16 ` [PATCH v2 23/23] dmaengine: sdxi: Add DMA engine provider Nathan Lynch via B4 Relay
2026-05-11 20:47 ` Frank Li
2026-05-11 22:28 ` Lynch, Nathan
2026-05-13 20:01 ` Frank Li
2026-05-13 22:57 ` 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=87pl24d0wd.fsf@amd.com \
--to=nathan.lynch@amd.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox