From: T Pratham <t-pratham@ti.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
Sebin Francis <sebin.francis@ti.com>,
Manorit Chawdhry <m-chawdhry@ti.com>,
Vishal Mahaveer <vishalm@ti.com>,
Praneeth Bajjuri <praneeth@ti.com>,
<linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 04/15] crypto: ti - Fix use-after-free of dev_data on DTHEv2 driver removal
Date: Thu, 24 Sep 2026 21:09:33 +0530 [thread overview]
Message-ID: <604ddec3-bf19-4a41-8fc3-c4ec949e4e03@ti.com> (raw)
In-Reply-To: <arNo63c8NOHkc5CH@gondor.apana.org.au>
On 9/23/26 11:21, Herbert Xu wrote:
> On Fri, Sep 18, 2026 at 03:52:34PM +0530, T Pratham wrote:
>> Each *_init_tfm() caches a pointer to the per-instance struct dthe_data
>> in its transform context (ctx->dev_data), but never takes a reference on
>> it. If there are tfms in progress when dthe_remove() is called, the devm
>> allocated dev_data gets freed. Then ctx->dev_data will point to a memory
>> that has been freed.
>>
>> Move dthe_data to req_ctx structs of algorithms, and store the device
>> pointer in tfm_ctx. Add a refcnt to struct dthe_data, which atomically
>> counts the number of requests enqueued in the crypto engine queue which
>> reference the dthe_data object.
>>
>> A waitqueue waits on this atomic counter to get back to zero in
>> dthe_remove() before doing the driver teardown.
>>
>> Fixes: 52f641bc63a46 ("crypto: ti - Add driver for DTHE V2 AES Engine (ECB, CBC)")
>> Signed-off-by: T Pratham <t-pratham@ti.com>
>> ---
>> drivers/crypto/ti/dthev2-aes.c | 74 +++++++++++++++++++++----------
>> drivers/crypto/ti/dthev2-common.c | 40 ++++++++++++++---
>> drivers/crypto/ti/dthev2-common.h | 52 ++++++++++++++++++++--
>> 3 files changed, 134 insertions(+), 32 deletions(-)
>
> Please check the Sashiko comments:
>
> https://sashiko.dev/#/patchset/20260918102245.2784000-1-t-pratham%40ti.com
>
> Thanks,
Hi Herbert,
For the patch 06/15's Sashiko review, it suggests to use
crypto_skcipher_set_reqsize_dma() in init. But this being similar to
crypto_skcipher_set_reqsize() which you have said will be deprecated and
set .cra_reqsize directly instead, this shouldn't be used as the correct
fix, right?
As an aside, my LLM suggests me to instead do:
- .cra_reqsize = sizeof(struct dthe_aes_req_ctx),
+ .cra_reqsize = sizeof(struct dthe_aes_req_ctx) + CRYPTO_DMA_PADDING,
Doesn't look to me that it is doing same thing as
crypto_skcipher_set_reqsize_dma(). Your thoughts?
--
Regards
T Pratham <t-pratham@ti.com>
next prev parent reply other threads:[~2026-09-24 15:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 10:22 [PATCH v5 00/15] Fix several issues in DTHEv2 driver T Pratham
2026-09-18 10:22 ` [PATCH v5 01/15] crypto: ti - Use list_first_entry_or_null() in dthe_get_dev() T Pratham
2026-09-18 10:22 ` [PATCH v5 02/15] crypto: ti - Fix spinlock inconsistency in DTHEv2 T Pratham
2026-09-18 10:22 ` [PATCH v5 03/15] crypto: ti - Fix potential memory corruption on highmem pages T Pratham
2026-09-18 10:22 ` [PATCH v5 04/15] crypto: ti - Fix use-after-free of dev_data on DTHEv2 driver removal T Pratham
2026-09-23 5:51 ` Herbert Xu
2026-09-24 15:39 ` T Pratham [this message]
2026-09-18 10:22 ` [PATCH v5 05/15] crypto: ti - Trim scatterlists to correct length in AES T Pratham
2026-09-18 10:22 ` [PATCH v5 06/15] crypto: ti - Align buffers to cacheline for DMA T Pratham
2026-09-18 10:22 ` [PATCH v5 07/15] crypto: ti - Separate padding buffer for src and dst T Pratham
2026-09-18 10:22 ` [PATCH v5 08/15] crypto: ti - Validate sg_nents_for_len() return value in DTHEv2 AES T Pratham
2026-09-18 10:22 ` [PATCH v5 09/15] crypto: ti - Validate sg_nents_for_len() return value in DTHEv2 AEAD T Pratham
2026-09-18 10:22 ` [PATCH v5 10/15] crypto: ti - Terminate DMA on all error paths in AES to clear descriptors T Pratham
2026-09-18 10:22 ` [PATCH v5 11/15] crypto: ti - Terminate DMA on all error paths in AEAD " T Pratham
2026-09-18 10:22 ` [PATCH v5 12/15] crypto: ti - Do AEAD software fallback on only ENOMEM T Pratham
2026-09-18 10:22 ` [PATCH v5 13/15] crypto: ti - Correct AEAD tag operations against dma cache invalidation T Pratham
2026-09-18 10:22 ` [PATCH v5 14/15] crypto: ti - Change lengths in AES to u64 to avoid potential overflows T Pratham
2026-09-18 10:22 ` [PATCH v5 15/15] crypto: ti - Change lengths in AEAD " T Pratham
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=604ddec3-bf19-4a41-8fc3-c4ec949e4e03@ti.com \
--to=t-pratham@ti.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-chawdhry@ti.com \
--cc=praneeth@ti.com \
--cc=sebin.francis@ti.com \
--cc=vishalm@ti.com \
/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
all inboxes | Powered by JetHome®