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: <7B16C43E-1C25-44B6-A4F0-B546935ECA27@bytedance.com>
Date:   Fri, 22 Apr 2022 14:58:33 +0800
From:   何磊 <helei.sig11@...edance.com>
To:     "Gonglei (Arei)" <arei.gonglei@...wei.com>
Cc:     何磊 <helei.sig11@...edance.com>,
        zhenwei pi <pizhenwei@...edance.com>,
        "mst@...hat.com" <mst@...hat.com>,
        "jasowang@...hat.com" <jasowang@...hat.com>,
        "herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "virtualization@...ts.linux-foundation.org" 
        <virtualization@...ts.linux-foundation.org>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "davem@...emloft.net" <davem@...emloft.net>
Subject: Re: [External] [PATCH v3 4/5] virtio-crypto: adjust dst_len at ops
 callback



> On Apr 21, 2022, at 9:46 PM, Gonglei (Arei) <arei.gonglei@...wei.com> wrote:
> 
> 
> 
>> -----Original Message-----
>> From: zhenwei pi [mailto:pizhenwei@...edance.com]
>> Sent: Thursday, April 21, 2022 6:40 PM
>> To: Gonglei (Arei) <arei.gonglei@...wei.com>; mst@...hat.com
>> Cc: jasowang@...hat.com; herbert@...dor.apana.org.au;
>> linux-kernel@...r.kernel.org; virtualization@...ts.linux-foundation.org;
>> linux-crypto@...r.kernel.org; helei.sig11@...edance.com;
>> davem@...emloft.net; zhenwei pi <pizhenwei@...edance.com>
>> Subject: [PATCH v3 4/5] virtio-crypto: adjust dst_len at ops callback
>> 
>> From: lei he <helei.sig11@...edance.com>
>> 
>> For some akcipher operations(eg, decryption of pkcs1pad(rsa)), the length of
>> returned result maybe less than akcipher_req->dst_len, we need to recalculate
>> the actual dst_len through the virt-queue protocol.
>> 
> OK ...
> 
>> Cc: Michael S. Tsirkin <mst@...hat.com>
>> Cc: Jason Wang <jasowang@...hat.com>
>> Cc: Gonglei <arei.gonglei@...wei.com>
>> Signed-off-by: lei he <helei.sig11@...edance.com>
>> Signed-off-by: zhenwei pi <pizhenwei@...edance.com>
>> ---
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
>> b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
>> index 9561bc2df62b..82db86e088c2 100644
>> --- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
>> +++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
>> @@ -90,9 +90,12 @@ static void
>> virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request *
>> 	}
>> 
>> 	akcipher_req = vc_akcipher_req->akcipher_req;
>> -	if (vc_akcipher_req->opcode != VIRTIO_CRYPTO_AKCIPHER_VERIFY)
>> +	if (vc_akcipher_req->opcode != VIRTIO_CRYPTO_AKCIPHER_VERIFY) {
>> +		/* actuall length maybe less than dst buffer */
>> +		akcipher_req->dst_len = len - sizeof(vc_req->status);
> 
> ...but why minus sizeof(vc_req->status)?

The len here indicates the total length of data written by the device. for encrypt/decrypt/sign,
the virt crypto device writes two parts of data: dst_data and status(virtio_crypto_inhdr). 
To obtain dst_len, the size of status needs to be subtracted.

> 
> 
> Regards,
> -Gonglei

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ