qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: zhenwei pi <pizhenwei@bytedance.com>
To: mst@redhat.com
Cc: Lei He <helei.sig11@bytedance.com>,
	arei.gonglei@huawei.com, qemu-devel@nongnu.org,
	Mauro Matteo Cascella <mcascell@redhat.com>,
	Xiao Lei <nop.leixiao@gmail.com>,
	Yongkang Jia <kangel@zju.edu.cn>, Yiming Tao <taoym@zju.edu.cn>
Subject: Re: [PATCH] cryptodev: Handle unexpected request to avoid crash
Date: Sun, 25 Jun 2023 08:00:17 +0800	[thread overview]
Message-ID: <b22dd57c-6e39-cfc7-7128-33447252468f@bytedance.com> (raw)
In-Reply-To: <A4856378-68F6-440B-A0C8-B13EEEF452BC@bytedance.com>

Hi Michael

Could you please apply this patch?

On 5/26/23 11:38, Lei He wrote:
> 
>> On Apr 27, 2023, at 16:05, zhenwei pi <pizhenwei@bytedance.com> wrote:
>>
>> Generally guest side should discover which services the device is
>> able to offer, then do requests on device.
>>
>> However it's also possible to break this rule in a guest. Handle
>> unexpected request here to avoid NULL pointer dereference.
>>
>> Fixes: e7a775fd ('cryptodev: Account statistics')
>> Cc: Gonglei <arei.gonglei@huawei.com>
>> Cc: Mauro Matteo Cascella <mcascell@redhat.com>
>> Cc: Xiao Lei <nop.leixiao@gmail.com>
>> Cc: Yongkang Jia <kangel@zju.edu.cn>
>> Reported-by: Yiming Tao <taoym@zju.edu.cn>
>> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
>> ---
>> backends/cryptodev.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/backends/cryptodev.c b/backends/cryptodev.c
>> index 94ca393cee..d3fe92d8c0 100644
>> --- a/backends/cryptodev.c
>> +++ b/backends/cryptodev.c
>> @@ -191,6 +191,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
>>      if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
>>          CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
>>          len = asym_op_info->src_len;
>> +
>> +        if (unlikely(!backend->asym_stat)) {
>> +            error_report("cryptodev: Unexpected asym operation");
>> +            return -VIRTIO_CRYPTO_NOTSUPP;
>> +        }
>>          switch (op_info->op_code) {
>>          case VIRTIO_CRYPTO_AKCIPHER_ENCRYPT:
>>              CryptodevAsymStatIncEncrypt(backend, len);
>> @@ -210,6 +215,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
>>      } else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
>>          CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
>>          len = sym_op_info->src_len;
>> +
>> +        if (unlikely(!backend->sym_stat)) {
>> +            error_report("cryptodev: Unexpected sym operation");
>> +            return -VIRTIO_CRYPTO_NOTSUPP;
>> +        }
>>          switch (op_info->op_code) {
>>          case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
>>              CryptodevSymStatIncEncrypt(backend, len);
>> -- 
>> 2.34.1
>>
> 
> Reviewed-by: Lei He <helei.sig11@bytedance.com>
> 
> 
> Best regards,
> Lei He
> --
> helei.sig11@bytedance.com
> 
> 
> 

-- 
zhenwei pi


      reply	other threads:[~2023-06-25  0:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27  8:05 [PATCH] cryptodev: Handle unexpected request to avoid crash zhenwei pi
2023-05-26  3:38 ` Lei He
2023-06-25  0:00   ` zhenwei pi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b22dd57c-6e39-cfc7-7128-33447252468f@bytedance.com \
    --to=pizhenwei@bytedance.com \
    --cc=arei.gonglei@huawei.com \
    --cc=helei.sig11@bytedance.com \
    --cc=kangel@zju.edu.cn \
    --cc=mcascell@redhat.com \
    --cc=mst@redhat.com \
    --cc=nop.leixiao@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=taoym@zju.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).