From: Herbert Xu <herbert@gondor.apana.org.au>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Antoine Tenart <atenart@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
upstream@airoha.com, Richard van Schagen <vschagen@icloud.com>
Subject: Re: [PATCH v8 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support
Date: Wed, 11 Dec 2024 17:39:27 +0800 [thread overview]
Message-ID: <Z1ldzyPKgoD8GZfx@gondor.apana.org.au> (raw)
In-Reply-To: <20241210204853.18765-4-ansuelsmth@gmail.com>
On Tue, Dec 10, 2024 at 09:48:33PM +0100, Christian Marangi wrote:
>
> +static int eip93_hash_export(struct ahash_request *req, void *out)
> +{
> + struct eip93_hash_reqctx *rctx = ahash_request_ctx(req);
> + struct eip93_hash_export_state *state = out;
> +
> + /* Save the first block in state data */
> + if (rctx->len) {
> + struct mkt_hash_block *block;
> +
> + block = list_first_entry(&rctx->blocks,
> + struct mkt_hash_block,
> + list);
> +
> + memcpy(state->data, block->data,
> + SHA256_BLOCK_SIZE - rctx->left_last);
> + }
> +
> + eip93_hash_export_sa_state(req, state);
> +
> + eip93_hash_free_data_blocks(req);
> + eip93_hash_free_sa_state(req);
> + eip93_hash_free_sa_record(req);
The export function should be idempotent so it shouldn't be freeing
anything.
In fact this indicates a bigger problem with how DMA is being used
in the driver. You shouldn't be leaving DMA memory mapped after
the init (or update) function completes. It is perfectly legal
for a user to call init and then abandon the request by freeing it
directly without ever calling final. In that case you will be
leaking the DMA mappings.
So make sure that DMA is mapped only when needed, and freed before
you call the user callback.
The import/export functions should only be touching kernel memory,
not DMA.
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
next prev parent reply other threads:[~2024-12-11 9:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 20:48 [PATCH v8 0/3] crypto: Add EIP-93 crypto engine support Christian Marangi
2024-12-10 20:48 ` [PATCH v8 1/3] spinlock: extend guard with spinlock_bh variants Christian Marangi
2024-12-10 20:48 ` [PATCH v8 2/3] dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine Christian Marangi
2024-12-10 20:48 ` [PATCH v8 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support Christian Marangi
2024-12-11 9:30 ` Herbert Xu
2024-12-11 11:39 ` Christian Marangi
2024-12-14 4:37 ` Herbert Xu
2024-12-14 13:32 ` Christian Marangi
2024-12-11 9:39 ` Herbert Xu [this message]
2024-12-11 11:40 ` Christian Marangi
2024-12-11 23:18 ` Herbert Xu
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=Z1ldzyPKgoD8GZfx@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=ansuelsmth@gmail.com \
--cc=atenart@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=justinstitt@google.com \
--cc=krzk+dt@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=robh@kernel.org \
--cc=upstream@airoha.com \
--cc=vschagen@icloud.com \
--cc=will@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