[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.0.1 54/59] virtio-crypto: fix NULL pointer dereference in virt
From: |
Michael Tokarev |
Subject: |
[Stable-8.0.1 54/59] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request |
Date: |
Tue, 23 May 2023 13:15:14 +0300 |
From: Mauro Matteo Cascella <mcascell@redhat.com>
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>
Message-Id: <20230509075317.1132301-1-mcascell@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: zhenwei pi<pizhenwei@bytedance.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 3e69908907f8d3dd20d5753b0777a6e3824ba824)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 802e1b9659..a1d122b9aa 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) {
--
2.39.2
- [Stable-8.0.1 43/59] linux-user: fix getgroups/setgroups allocations, (continued)
- [Stable-8.0.1 43/59] linux-user: fix getgroups/setgroups allocations, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 44/59] migration: Handle block device inactivation failures better, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 46/59] migration: Attempt disk reactivation in more failure scenarios, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 47/59] target/arm: Fix vd == vm overlap in sve_ldff1_z, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 48/59] scsi-generic: fix buffer overflow on block limits inquiry, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 50/59] target/i386: fix avx2 instructions vzeroall and vpermdq, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 51/59] vhost: fix possible wrap in SVQ descriptor ring, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 52/59] hw/pci: Disable PCI_ERR_UNCOR_MASK register for machine type < 8.0, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 49/59] target/i386: fix operand size for VCOMI/VUCOMI instructions, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 53/59] virtio-net: not enable vq reset feature unconditionally, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 54/59] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request,
Michael Tokarev <=
- [Stable-8.0.1 55/59] aio-posix: do not nest poll handlers, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 56/59] tested: add test for nested aio_poll() in poll handlers, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 57/59] block: compile out assert_bdrv_graph_readable() by default, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 58/59] graph-lock: Disable locking for now, Michael Tokarev, 2023/05/23
- [Stable-8.0.1 59/59] nbd/server: Fix drained_poll to wake coroutine in right AioContext, Michael Tokarev, 2023/05/23