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: <1409091619.25467.1626259183269.JavaMail.zimbra@nod.at>
Date:   Wed, 14 Jul 2021 12:39:43 +0200 (CEST)
From:   Richard Weinberger <richard@....at>
To:     Ahmad Fatoum <a.fatoum@...gutronix.de>
Cc:     "open list, ASYMMETRIC KEYS" <keyrings@...r.kernel.org>,
        david <david@...ma-star.at>, David Howells <dhowells@...hat.com>,
        davem <davem@...emloft.net>, festevam <festevam@...il.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        James Bottomley <jejb@...ux.ibm.com>,
        James Morris <jmorris@...ei.org>,
        Jarkko Sakkinen <jarkko@...nel.org>,
        Jonathan Corbet <corbet@....net>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
        Linux Doc Mailing List <linux-doc@...r.kernel.org>,
        linux-integrity <linux-integrity@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        LSM <linux-security-module@...r.kernel.org>,
        Mimi Zohar <zohar@...ux.ibm.com>,
        linux-imx <linux-imx@....com>, kernel <kernel@...gutronix.de>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        "Serge E. Hallyn" <serge@...lyn.com>,
        shawnguo <shawnguo@...nel.org>
Subject: Re: [PATCH 1/3] crypto: mxs-dcp: Add support for hardware provided
 keys

Ahmad,

----- Ursprüngliche Mail -----
> Von: "Ahmad Fatoum" <a.fatoum@...gutronix.de>
> Let's trade reviews to get the ball rolling?

Sounds like a fair deal. :-)

[...]

>> --- a/drivers/crypto/mxs-dcp.c
>> +++ b/drivers/crypto/mxs-dcp.c
>> @@ -15,6 +15,7 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/stmp_device.h>
>>  #include <linux/clk.h>
>> +#include <linux/mxs-dcp.h>
> 
> The CAAM specific headers are in <soc/fsl/*.h>.
> Should this be done likewise here as well?

I have no preferences. If soc/fsl/ is the way to go, fine by me.

[...]

>> @@ -219,15 +224,18 @@ static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
>>  	struct dcp *sdcp = global_sdcp;
>>  	struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
>>  	struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);
>> +	dma_addr_t src_phys, dst_phys, key_phys = {0};
> 
> Why = {0}; ? dma_addr_t is a scalar type and the value is always
> written here before access.

Initializing a scalar with {} is allowed in C, the braces are optional.
I like the braces because it works even when the underlaying type changes.
But that's just a matter of taste.

key_phys is initialized because it triggered a false positive gcc warning
on one of my targets. Let me re-run again to be sure, the code saw a lot of
refactoring since that.
 
[...]
  
>> +static int mxs_dcp_aes_setrefkey(struct crypto_skcipher *tfm, const u8 *key,
>> +				 unsigned int len)
>> +{
>> +	struct dcp_async_ctx *actx = crypto_skcipher_ctx(tfm);
>> +	int ret = -EINVAL;
>> +
>> +	if (len != DCP_PAES_KEYSIZE)
>> +		goto out;
> 
> Nitpick: there is no cleanup, so why not return -EINVAL here
> and unconditionally return 0 below?

What is the benefit?
Usually I try to use goto to have a single exit point of a function
but I don't have a strong preference...

>> +
>> +	actx->key_len = len;
>> +	actx->refkey = true;
>> +
>> +	switch (key[0]) {
>> +	case DCP_PAES_KEY_SLOT0:
>> +	case DCP_PAES_KEY_SLOT1:
>> +	case DCP_PAES_KEY_SLOT2:
>> +	case DCP_PAES_KEY_SLOT3:
>> +	case DCP_PAES_KEY_UNIQUE:
>> +	case DCP_PAES_KEY_OTP:
>> +		memcpy(actx->key, key, len);
>> +		ret = 0;
>> +	}
> 
> In the error case you return -EINVAL below, but you still write
> into actx. Is that intentional?

You mean acts->key_len and actk->refkey?
Is this a problem?

Thanks,
//richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ