lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z1ldzyPKgoD8GZfx@gondor.apana.org.au>
Date: Wed, 11 Dec 2024 17:39:27 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: "David S. Miller" <davem@...emloft.net>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Antoine Tenart <atenart@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
	Waiman Long <longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>, linux-crypto@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev, upstream@...oha.com,
	Richard van Schagen <vschagen@...oud.com>
Subject: Re: [PATCH v8 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto
 engine support

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@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ