From: zhenwei pi <pizhenwei@bytedance.com>
To: Mauro Matteo Cascella <mcascell@redhat.com>, qemu-devel@nongnu.org
Cc: mst@redhat.com, arei.gonglei@huawei.com, taoym@zju.edu.cn
Subject: Re: [PATCH v2] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
Date: Tue, 9 May 2023 20:52:15 +0800 [thread overview]
Message-ID: <20b5cb57-aa5f-452d-2c51-0d1751931b49@bytedance.com> (raw)
In-Reply-To: <20230509075317.1132301-1-mcascell@redhat.com>
LGTM. Thanks!
Reviewed-by: zhenwei pi<pizhenwei@bytedance.com>
On 5/9/23 15:53, Mauro Matteo Cascella wrote:
> Ensure op_info is not NULL in case of QCRYPTODEV_BACKEND_ALG_SYM algtype.
>
> Fixes: 0e660a6f90a ("crypto: Introduce RSA algorithm")
> Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
> Reported-by: Yiming Tao <taoym@zju.edu.cn>
> ---
> v2:
> - updated 'Fixes:' tag
>
> hw/virtio/virtio-crypto.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
> index 2fe804510f..c729a1f79e 100644
> --- a/hw/virtio/virtio-crypto.c
> +++ b/hw/virtio/virtio-crypto.c
> @@ -476,15 +476,17 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
> size_t max_len;
> CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
>
> - max_len = op_info->iv_len +
> - op_info->aad_len +
> - op_info->src_len +
> - op_info->dst_len +
> - op_info->digest_result_len;
> -
> - /* Zeroize and free request data structure */
> - memset(op_info, 0, sizeof(*op_info) + max_len);
> - g_free(op_info);
> + if (op_info) {
> + max_len = op_info->iv_len +
> + op_info->aad_len +
> + op_info->src_len +
> + op_info->dst_len +
> + op_info->digest_result_len;
> +
> + /* Zeroize and free request data structure */
> + memset(op_info, 0, sizeof(*op_info) + max_len);
> + g_free(op_info);
> + }
> } else if (req->flags == QCRYPTODEV_BACKEND_ALG_ASYM) {
> CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
> if (op_info) {
--
zhenwei pi
prev parent reply other threads:[~2023-05-09 12:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 7:53 [PATCH v2] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request Mauro Matteo Cascella
2023-05-09 9:32 ` Gonglei (Arei) via
2023-05-09 12:52 ` 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=20b5cb57-aa5f-452d-2c51-0d1751931b49@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=arei.gonglei@huawei.com \
--cc=mcascell@redhat.com \
--cc=mst@redhat.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).