mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 05:20:50 +00:00
virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
Ensure op_info is not NULL in case of QCRYPTODEV_BACKEND_ALG_SYM algtype.
Fixes: 0e660a6f90
("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>
(Mjt: context tweak after 999c789f00 cryptodev: Introduce cryptodev alg type in QAPI)
This commit is contained in:
parent
dd63d3a5b8
commit
926a8380f2
@ -476,15 +476,17 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
|
|||||||
size_t max_len;
|
size_t max_len;
|
||||||
CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
|
CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
|
||||||
|
|
||||||
max_len = op_info->iv_len +
|
if (op_info) {
|
||||||
op_info->aad_len +
|
max_len = op_info->iv_len +
|
||||||
op_info->src_len +
|
op_info->aad_len +
|
||||||
op_info->dst_len +
|
op_info->src_len +
|
||||||
op_info->digest_result_len;
|
op_info->dst_len +
|
||||||
|
op_info->digest_result_len;
|
||||||
|
|
||||||
/* Zeroize and free request data structure */
|
/* Zeroize and free request data structure */
|
||||||
memset(op_info, 0, sizeof(*op_info) + max_len);
|
memset(op_info, 0, sizeof(*op_info) + max_len);
|
||||||
g_free(op_info);
|
g_free(op_info);
|
||||||
|
}
|
||||||
} else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
|
} else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
|
||||||
CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
|
CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
|
||||||
if (op_info) {
|
if (op_info) {
|
||||||
|
Loading…
Reference in New Issue
Block a user