[PATCH v4 0/9] crypto: virtio: Some bugfix and enhancement

Bibo Mao posted 9 patches 1 month, 3 weeks ago
There is a newer version of this series
drivers/crypto/virtio/virtio_crypto_common.h  |   2 +-
drivers/crypto/virtio/virtio_crypto_core.c    |   5 +
.../virtio/virtio_crypto_skcipher_algs.c      | 113 +++++++++---------
3 files changed, 62 insertions(+), 58 deletions(-)
[PATCH v4 0/9] crypto: virtio: Some bugfix and enhancement
Posted by Bibo Mao 1 month, 3 weeks ago
There is problem when multiple processes add encrypt/decrypt requests
with virtio crypto device and spinlock is missing with command response
handling. Also there is duplicated virtqueue_kick() without lock hold.

Here these two issues are fixed and the others are code clean up, such as
use common APIs for block size and iv size etc.

---
v3 ... v4:
  1. Remove patch 10 which adds ECB AES algo, since application and qemu
     backend emulation is not ready for ECB AES algo.
  2. Add Cc stable tag with patch 2 which removes duplicated
     virtqueue_kick() without lock hold.

v2 ... v3:
  1. Remove NULL checking with req_data where kfree() is called, since
     NULL pointer is workable with kfree() API.
  2. In patch 7 and patch 8, req_data and IV buffer which are preallocated
     are sensitive data, memzero_explicit() is used even on error path
     handling.
  3. Remove duplicated virtqueue_kick() in new patch 2, since it is
     already called in previous __virtio_crypto_skcipher_do_req().

v1 ... v2:
  1. Add Fixes tag with patch 1.
  2. Add new patch 2 - patch 9 to add ecb aes algo support.
---
Bibo Mao (9):
  crypto: virtio: Add spinlock protection with virtqueue notification
  crypto: virtio: Remove duplicated virtqueue_kick in
    virtio_crypto_skcipher_crypt_req
  crypto: virtio: Replace package id with numa node id
  crypto: virtio: Add algo pointer in virtio_crypto_skcipher_ctx
  crypto: virtio: Use generic API aes_check_keylen()
  crypto: virtio: Remove AES specified marcro AES_BLOCK_SIZE
  crypto: virtio: Add req_data with structure virtio_crypto_sym_request
  crypto: virtio: Add IV buffer in structure virtio_crypto_sym_request
  crypto: virtio: Add skcipher support without IV

 drivers/crypto/virtio/virtio_crypto_common.h  |   2 +-
 drivers/crypto/virtio/virtio_crypto_core.c    |   5 +
 .../virtio/virtio_crypto_skcipher_algs.c      | 113 +++++++++---------
 3 files changed, 62 insertions(+), 58 deletions(-)


base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
-- 
2.39.3
Re: [PATCH v4 0/9] crypto: virtio: Some bugfix and enhancement
Posted by Michael S. Tsirkin 1 month, 2 weeks ago
On Thu, Dec 18, 2025 at 11:48:37AM +0800, Bibo Mao wrote:
> There is problem when multiple processes add encrypt/decrypt requests
> with virtio crypto device and spinlock is missing with command response
> handling. Also there is duplicated virtqueue_kick() without lock hold.
> 
> Here these two issues are fixed and the others are code clean up, such as
> use common APIs for block size and iv size etc.

series:
Acked-by: Michael S. Tsirkin <mst@redhat.com>

but you did not CC maintainers, you really should if you want this
applied.

> ---
> v3 ... v4:
>   1. Remove patch 10 which adds ECB AES algo, since application and qemu
>      backend emulation is not ready for ECB AES algo.
>   2. Add Cc stable tag with patch 2 which removes duplicated
>      virtqueue_kick() without lock hold.
> 
> v2 ... v3:
>   1. Remove NULL checking with req_data where kfree() is called, since
>      NULL pointer is workable with kfree() API.
>   2. In patch 7 and patch 8, req_data and IV buffer which are preallocated
>      are sensitive data, memzero_explicit() is used even on error path
>      handling.
>   3. Remove duplicated virtqueue_kick() in new patch 2, since it is
>      already called in previous __virtio_crypto_skcipher_do_req().
> 
> v1 ... v2:
>   1. Add Fixes tag with patch 1.
>   2. Add new patch 2 - patch 9 to add ecb aes algo support.
> ---
> Bibo Mao (9):
>   crypto: virtio: Add spinlock protection with virtqueue notification
>   crypto: virtio: Remove duplicated virtqueue_kick in
>     virtio_crypto_skcipher_crypt_req
>   crypto: virtio: Replace package id with numa node id
>   crypto: virtio: Add algo pointer in virtio_crypto_skcipher_ctx
>   crypto: virtio: Use generic API aes_check_keylen()
>   crypto: virtio: Remove AES specified marcro AES_BLOCK_SIZE
>   crypto: virtio: Add req_data with structure virtio_crypto_sym_request
>   crypto: virtio: Add IV buffer in structure virtio_crypto_sym_request
>   crypto: virtio: Add skcipher support without IV
> 
>  drivers/crypto/virtio/virtio_crypto_common.h  |   2 +-
>  drivers/crypto/virtio/virtio_crypto_core.c    |   5 +
>  .../virtio/virtio_crypto_skcipher_algs.c      | 113 +++++++++---------
>  3 files changed, 62 insertions(+), 58 deletions(-)
> 
> 
> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
> -- 
> 2.39.3
Re: [PATCH v4 0/9] crypto: virtio: Some bugfix and enhancement
Posted by Bibo Mao 1 month, 1 week ago

On 2025/12/26 下午10:45, Michael S. Tsirkin wrote:
> On Thu, Dec 18, 2025 at 11:48:37AM +0800, Bibo Mao wrote:
>> There is problem when multiple processes add encrypt/decrypt requests
>> with virtio crypto device and spinlock is missing with command response
>> handling. Also there is duplicated virtqueue_kick() without lock hold.
>>
>> Here these two issues are fixed and the others are code clean up, such as
>> use common APIs for block size and iv size etc.
> 
> series:
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> 
> but you did not CC maintainers, you really should if you want this
> applied.
Oh, sorry, it is the first time I send patch relative with crypto 
subsystem.

Add Herbert and David, need I send a fresh version?

Regards
Bibo Mao
> 
>> ---
>> v3 ... v4:
>>    1. Remove patch 10 which adds ECB AES algo, since application and qemu
>>       backend emulation is not ready for ECB AES algo.
>>    2. Add Cc stable tag with patch 2 which removes duplicated
>>       virtqueue_kick() without lock hold.
>>
>> v2 ... v3:
>>    1. Remove NULL checking with req_data where kfree() is called, since
>>       NULL pointer is workable with kfree() API.
>>    2. In patch 7 and patch 8, req_data and IV buffer which are preallocated
>>       are sensitive data, memzero_explicit() is used even on error path
>>       handling.
>>    3. Remove duplicated virtqueue_kick() in new patch 2, since it is
>>       already called in previous __virtio_crypto_skcipher_do_req().
>>
>> v1 ... v2:
>>    1. Add Fixes tag with patch 1.
>>    2. Add new patch 2 - patch 9 to add ecb aes algo support.
>> ---
>> Bibo Mao (9):
>>    crypto: virtio: Add spinlock protection with virtqueue notification
>>    crypto: virtio: Remove duplicated virtqueue_kick in
>>      virtio_crypto_skcipher_crypt_req
>>    crypto: virtio: Replace package id with numa node id
>>    crypto: virtio: Add algo pointer in virtio_crypto_skcipher_ctx
>>    crypto: virtio: Use generic API aes_check_keylen()
>>    crypto: virtio: Remove AES specified marcro AES_BLOCK_SIZE
>>    crypto: virtio: Add req_data with structure virtio_crypto_sym_request
>>    crypto: virtio: Add IV buffer in structure virtio_crypto_sym_request
>>    crypto: virtio: Add skcipher support without IV
>>
>>   drivers/crypto/virtio/virtio_crypto_common.h  |   2 +-
>>   drivers/crypto/virtio/virtio_crypto_core.c    |   5 +
>>   .../virtio/virtio_crypto_skcipher_algs.c      | 113 +++++++++---------
>>   3 files changed, 62 insertions(+), 58 deletions(-)
>>
>>
>> base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
>> -- 
>> 2.39.3