* [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
@ 2023-05-08 15:01 Mauro Matteo Cascella
2023-05-09 1:02 ` Gonglei (Arei) via
0 siblings, 1 reply; 4+ messages in thread
From: Mauro Matteo Cascella @ 2023-05-08 15:01 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, arei.gonglei, pizhenwei, taoym, mcascell
Ensure op_info is not NULL in case of QCRYPTODEV_BACKEND_ALG_SYM algtype.
Fixes: 02ed3e7c ("virtio-crypto: zeroize the key material before free")
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Reported-by: Yiming Tao <taoym@zju.edu.cn>
---
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) {
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
2023-05-08 15:01 [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request Mauro Matteo Cascella
@ 2023-05-09 1:02 ` Gonglei (Arei) via
2023-05-09 1:45 ` zhenwei pi
0 siblings, 1 reply; 4+ messages in thread
From: Gonglei (Arei) via @ 2023-05-09 1:02 UTC (permalink / raw)
To: Mauro Matteo Cascella, qemu-devel@nongnu.org
Cc: mst@redhat.com, pizhenwei@bytedance.com, taoym@zju.edu.cn
> -----Original Message-----
> From: Mauro Matteo Cascella [mailto:mcascell@redhat.com]
> Sent: Monday, May 8, 2023 11:02 PM
> To: qemu-devel@nongnu.org
> Cc: mst@redhat.com; Gonglei (Arei) <arei.gonglei@huawei.com>;
> pizhenwei@bytedance.com; taoym@zju.edu.cn; mcascell@redhat.com
> Subject: [PATCH] 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: 02ed3e7c ("virtio-crypto: zeroize the key material before free")
I have to say the fixes is incorrect. The bug was introduced by commit 0e660a6f90a, which
changed the semantic meaning of request-> flag.
Regards,
-Gonglei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RE: [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
2023-05-09 1:02 ` Gonglei (Arei) via
@ 2023-05-09 1:45 ` zhenwei pi
2023-05-09 7:54 ` Mauro Matteo Cascella
0 siblings, 1 reply; 4+ messages in thread
From: zhenwei pi @ 2023-05-09 1:45 UTC (permalink / raw)
To: Mauro Matteo Cascella, qemu-devel@nongnu.org
Cc: mst@redhat.com, taoym@zju.edu.cn, Gonglei (Arei)
On 5/9/23 09:02, Gonglei (Arei) wrote:
>
>
>> -----Original Message-----
>> From: Mauro Matteo Cascella [mailto:mcascell@redhat.com]
>> Sent: Monday, May 8, 2023 11:02 PM
>> To: qemu-devel@nongnu.org
>> Cc: mst@redhat.com; Gonglei (Arei) <arei.gonglei@huawei.com>;
>> pizhenwei@bytedance.com; taoym@zju.edu.cn; mcascell@redhat.com
>> Subject: [PATCH] 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: 02ed3e7c ("virtio-crypto: zeroize the key material before free")
>
> I have to say the fixes is incorrect. The bug was introduced by commit 0e660a6f90a, which
> changed the semantic meaning of request-> flag.
>
> Regards,
> -Gonglei
>
Hi Mauro
Agree with Lei, could you please change the Fixes as Lei suggested?
--
zhenwei pi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RE: [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request
2023-05-09 1:45 ` zhenwei pi
@ 2023-05-09 7:54 ` Mauro Matteo Cascella
0 siblings, 0 replies; 4+ messages in thread
From: Mauro Matteo Cascella @ 2023-05-09 7:54 UTC (permalink / raw)
To: zhenwei pi
Cc: qemu-devel@nongnu.org, mst@redhat.com, taoym@zju.edu.cn,
Gonglei (Arei)
On Tue, May 9, 2023 at 3:47 AM zhenwei pi <pizhenwei@bytedance.com> wrote:
>
>
>
> On 5/9/23 09:02, Gonglei (Arei) wrote:
> >
> >
> >> -----Original Message-----
> >> From: Mauro Matteo Cascella [mailto:mcascell@redhat.com]
> >> Sent: Monday, May 8, 2023 11:02 PM
> >> To: qemu-devel@nongnu.org
> >> Cc: mst@redhat.com; Gonglei (Arei) <arei.gonglei@huawei.com>;
> >> pizhenwei@bytedance.com; taoym@zju.edu.cn; mcascell@redhat.com
> >> Subject: [PATCH] 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: 02ed3e7c ("virtio-crypto: zeroize the key material before free")
> >
> > I have to say the fixes is incorrect. The bug was introduced by commit 0e660a6f90a, which
> > changed the semantic meaning of request-> flag.
> >
> > Regards,
> > -Gonglei
> >
>
> Hi Mauro
>
> Agree with Lei, could you please change the Fixes as Lei suggested?
Sent v2.
Thanks!
> --
> zhenwei pi
>
--
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-09 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-08 15:01 [PATCH] virtio-crypto: fix NULL pointer dereference in virtio_crypto_free_request Mauro Matteo Cascella
2023-05-09 1:02 ` Gonglei (Arei) via
2023-05-09 1:45 ` zhenwei pi
2023-05-09 7:54 ` Mauro Matteo Cascella
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).