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: <c7dbadbf-dade-fb1e-bda3-d23d567c620f@linux.alibaba.com>
Date:   Mon, 30 Jan 2023 15:34:42 +0800
From:   Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
To:     Herbert Xu <herbert@...dor.apana.org.au>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, linux-crypto@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Ard Biesheuvel <ardb@...nel.org>
Subject: Re: [PATCH] crypto: arm64/sm4 - Fix possible crash in GCM cryption

Hi Herbert,

On 1/18/23 10:54 PM, Herbert Xu wrote:
> On Wed, Jan 18, 2023 at 10:19:28PM +0800, Tianjia Zhang wrote:
>> When the cryption total length is zero, GCM cryption call
>> skcipher_walk_done() will cause an unexpected crash, so skip calling
>> this function to avoid possible crash when the GCM cryption length
>> is equal to zero.
>>
>> Fixes: ae1b83c7d572 ("crypto: arm64/sm4 - add CE implementation for GCM mode")
>> Signed-off-by: Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
>> ---
>>   arch/arm64/crypto/sm4-ce-gcm-glue.c | 12 +++++++-----
>>   1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm64/crypto/sm4-ce-gcm-glue.c b/arch/arm64/crypto/sm4-ce-gcm-glue.c
>> index c450a2025ca9..9b63bcf9aa85 100644
>> --- a/arch/arm64/crypto/sm4-ce-gcm-glue.c
>> +++ b/arch/arm64/crypto/sm4-ce-gcm-glue.c
>> @@ -178,11 +178,13 @@ static int gcm_crypt(struct aead_request *req, struct skcipher_walk *walk,
>>   
>>   		kernel_neon_end();
>>   
>> -		err = skcipher_walk_done(walk, tail);
>> -		if (err)
>> -			return err;
>> -		if (walk->nbytes)
>> -			kernel_neon_begin();
>> +		if (walk->nbytes) {
> 
> Please do
> 		if (!walk->nbytes)
> 			break;

Thanks for the suggestion, a new patch has been sent.

> 
> As an additional improvement, the tail calculation can be removed
> entirely because you already set the chunksize so the walker should
> only be feeding you multiples of chunksize except at the end.
> 
> Cheers
I printed the walk->nbytes of each iteration of the walker, it is not
always multiples of chunksize except at the end when the algorithm test
manager is turned on.

For example, during a GCM encryption process, I get data like this:

     total = 4014, nbytes = 2078, tail = 14
     total = 1950, nbytes = 16, tail = 0
     total = 1934, nbytes = 311, tail = 7
     total = 1630, nbytes = 16, tail = 0
     total = 1614, nbytes = 16, tail = 0
     total = 1598, nbytes = 1598, tail = 14

Is my understanding wrong?

Best regards,
Tianjia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ