* Re: [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) [not found] ` <20250603124217.957116-3-t-pratham@ti.com> @ 2025-06-11 9:53 ` Herbert Xu 2025-06-12 10:15 ` T Pratham 2025-06-18 17:53 ` Vinod Koul 0 siblings, 2 replies; 4+ messages in thread From: Herbert Xu @ 2025-06-11 9:53 UTC (permalink / raw) To: T Pratham Cc: David S. Miller, Kamlesh Gurudasani, Vignesh Raghavendra, Praneeth Bajjuri, Manorit Chawdhry, linux-kernel, linux-crypto, Vinod Koul, dmaengine On Tue, Jun 03, 2025 at 06:07:29PM +0530, T Pratham wrote: > > + // Need to do a timeout to ensure finalise gets called if DMA callback fails for any reason > + ret = wait_for_completion_timeout(&rctx->aes_compl, msecs_to_jiffies(DTHE_DMA_TIMEOUT_MS)); This doesn't look safe. What if the callback is invoked after a timeout? That would be a UAF. Does the DMA engine provide any timeout mechanism? If not, then you could do it with a delayed work struct. Just make sure that you cancel the work struct in the normal path callback. Vice versa you need to terminate the DMA job in the timeout work struct. Cheers, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) 2025-06-11 9:53 ` [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) Herbert Xu @ 2025-06-12 10:15 ` T Pratham 2025-06-16 2:49 ` Herbert Xu 2025-06-18 17:53 ` Vinod Koul 1 sibling, 1 reply; 4+ messages in thread From: T Pratham @ 2025-06-12 10:15 UTC (permalink / raw) To: Herbert Xu Cc: David S. Miller, Kamlesh Gurudasani, Vignesh Raghavendra, Praneeth Bajjuri, Manorit Chawdhry, linux-kernel, linux-crypto, Vinod Koul, dmaengine On 11/06/25 15:23, Herbert Xu wrote: > On Tue, Jun 03, 2025 at 06:07:29PM +0530, T Pratham wrote: >> >> + // Need to do a timeout to ensure finalise gets called if DMA callback fails for any reason >> + ret = wait_for_completion_timeout(&rctx->aes_compl, msecs_to_jiffies(DTHE_DMA_TIMEOUT_MS)); > > This doesn't look safe. What if the callback is invoked after a > timeout? That would be a UAF. > > Does the DMA engine provide any timeout mechanism? If not, then > you could do it with a delayed work struct. Just make sure that > you cancel the work struct in the normal path callback. Vice versa > you need to terminate the DMA job in the timeout work struct. > > Cheers, Calling dma_terminate_sync() here should suffice I presume? I'll update the code accordingly. Regards T Pratham <t-pratham@ti.com> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) 2025-06-12 10:15 ` T Pratham @ 2025-06-16 2:49 ` Herbert Xu 0 siblings, 0 replies; 4+ messages in thread From: Herbert Xu @ 2025-06-16 2:49 UTC (permalink / raw) To: T Pratham Cc: David S. Miller, Kamlesh Gurudasani, Vignesh Raghavendra, Praneeth Bajjuri, Manorit Chawdhry, linux-kernel, linux-crypto, Vinod Koul, dmaengine On Thu, Jun 12, 2025 at 03:45:54PM +0530, T Pratham wrote: > > Calling dma_terminate_sync() here should suffice I presume? I'll update the code accordingly. This is just me having a skim through the DMA engine API. Vinod, could you please confirm whether this is how timeouts should be dealt with through the DMA engine? Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) 2025-06-11 9:53 ` [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) Herbert Xu 2025-06-12 10:15 ` T Pratham @ 2025-06-18 17:53 ` Vinod Koul 1 sibling, 0 replies; 4+ messages in thread From: Vinod Koul @ 2025-06-18 17:53 UTC (permalink / raw) To: Herbert Xu Cc: T Pratham, David S. Miller, Kamlesh Gurudasani, Vignesh Raghavendra, Praneeth Bajjuri, Manorit Chawdhry, linux-kernel, linux-crypto, dmaengine On 11-06-25, 17:53, Herbert Xu wrote: > On Tue, Jun 03, 2025 at 06:07:29PM +0530, T Pratham wrote: > > > > + // Need to do a timeout to ensure finalise gets called if DMA callback fails for any reason > > + ret = wait_for_completion_timeout(&rctx->aes_compl, msecs_to_jiffies(DTHE_DMA_TIMEOUT_MS)); > > This doesn't look safe. What if the callback is invoked after a > timeout? That would be a UAF. > > Does the DMA engine provide any timeout mechanism? If not, then > you could do it with a delayed work struct. Just make sure that > you cancel the work struct in the normal path callback. Vice versa > you need to terminate the DMA job in the timeout work struct. Typically no. Most of the hardware may not have capability, so we have apis to terminate. -- ~Vinod ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-18 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250603124217.957116-1-t-pratham@ti.com>
[not found] ` <20250603124217.957116-3-t-pratham@ti.com>
2025-06-11 9:53 ` [PATCH v5 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) Herbert Xu
2025-06-12 10:15 ` T Pratham
2025-06-16 2:49 ` Herbert Xu
2025-06-18 17:53 ` Vinod Koul
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox