All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - unmap descriptor before completing cookie
@ 2026-10-10 12:50 Wolfram Sang
  2026-10-10 13:01 ` sashiko-bot
  2026-10-12 10:43 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Wolfram Sang @ 2026-10-10 12:50 UTC (permalink / raw)
  To: dmaengine
  Cc: Wolfram Sang, Tom Lendacky, John Allen, Herbert Xu,
	David S. Miller, linux-crypto

To ensure that buffers are flushed, make sure that the descriptor gets
unmapped before completing the cookie.

Link: https://lore.kernel.org/r/20261009093745.539924-1-vkoul@kernel.org
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Build tested only.

 drivers/crypto/ccp/ccp-dmaengine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
index b386a7063818..02c6c5fc7db1 100644
--- a/drivers/crypto/ccp/ccp-dmaengine.c
+++ b/drivers/crypto/ccp/ccp-dmaengine.c
@@ -224,8 +224,8 @@ static struct ccp_dma_desc *ccp_handle_active_desc(struct ccp_dma_chan *chan,
 				"%s - tx %d complete, status=%u\n", __func__,
 				desc->tx_desc.cookie, desc->status);
 
-			dma_cookie_complete(tx_desc);
 			dma_descriptor_unmap(tx_desc);
+			dma_cookie_complete(tx_desc);
 		}
 
 		desc = __ccp_next_dma_desc(chan, desc);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccp - unmap descriptor before completing cookie
  2026-10-10 12:50 [PATCH] crypto: ccp - unmap descriptor before completing cookie Wolfram Sang
@ 2026-10-10 13:01 ` sashiko-bot
  2026-10-12 10:43 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-10 13:01 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Frank.Li, dmaengine, vkoul

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] crypto: ccp: silent error swallowing due to cleared dma cookie
--

commit c8a251448dee088f8a410c932932372165225507
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>

crypto: ccp - unmap descriptor before completing cookie

To ensure that buffers are flushed, make sure that the descriptor gets
unmapped before completing the cookie.

Link: https://lore.kernel.org/r/20261009093745.539924-1-vkoul@kernel.org

> diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
> index b386a7063818b..02c6c5fc7db1f 100644
> --- a/drivers/crypto/ccp/ccp-dmaengine.c
> +++ b/drivers/crypto/ccp/ccp-dmaengine.c
> @@ -224,8 +224,8 @@ static struct ccp_dma_desc *ccp_handle_active_desc(struct ccp_dma_chan *chan,
>  				"%s - tx %d complete, status=%u\n", __func__,
>  				desc->tx_desc.cookie, desc->status);
>  
> -			dma_cookie_complete(tx_desc);
>  			dma_descriptor_unmap(tx_desc);
> +			dma_cookie_complete(tx_desc);

[Severity: High]
Does this clear the cookie to 0, preventing later error checking in
ccp_tx_status()?

When ccp_tx_status() attempts to find the completed descriptor to check for
errors, it skips the descriptor because its cookie was zeroed by
dma_cookie_complete():

drivers/crypto/ccp/ccp-dmaengine.c:ccp_tx_status() {
    ...
		list_for_each_entry(desc, &chan->complete, entry) {
			if (desc->tx_desc.cookie != cookie)
				continue;

			ret = desc->status;
			break;
		}
    ...
}

Since the cookie no longer matches, ccp_tx_status() drops the DMA_ERROR state
and erroneously returns DMA_COMPLETE.

Additionally, a few lines later in ccp_handle_active_desc(), the callback
invocation passes NULL for the result:

drivers/crypto/ccp/ccp-dmaengine.c:ccp_handle_active_desc() {
    ...
		if (tx_desc) {
			dmaengine_desc_get_callback_invoke(tx_desc, NULL);
    ...
}

Does passing NULL here cause dmaengine to report DMA_TRANS_NOERROR to the
client's callback even when the status is DMA_ERROR? This sequence appears
to completely swallow DMA and cryptographic hardware failures.

>  		}
>  
>  		desc = __ccp_next_dma_desc(chan, desc);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010125001.19300-3-wsa+renesas@sang-engineering.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccp - unmap descriptor before completing cookie
  2026-10-10 12:50 [PATCH] crypto: ccp - unmap descriptor before completing cookie Wolfram Sang
  2026-10-10 13:01 ` sashiko-bot
@ 2026-10-12 10:43 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2026-10-12 10:43 UTC (permalink / raw)
  To: dmaengine
  Cc: Tom Lendacky, John Allen, Herbert Xu, David S. Miller,
	linux-crypto

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

On Sat, Oct 10, 2026 at 02:50:03PM +0200, Wolfram Sang wrote:
> To ensure that buffers are flushed, make sure that the descriptor gets
> unmapped before completing the cookie.
> 
> Link: https://lore.kernel.org/r/20261009093745.539924-1-vkoul@kernel.org
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

I'd like to drop this patch because Sashiko reported an issue with it
which I am not able to analyze.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-12 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10 12:50 [PATCH] crypto: ccp - unmap descriptor before completing cookie Wolfram Sang
2026-10-10 13:01 ` sashiko-bot
2026-10-12 10:43 ` Wolfram Sang

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.