From: zhenwei pi <zhenwei.pi@linux.dev>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, arei.gonglei@huawei.com,
nakamurajames123@gmail.com, qemu-security@nongnu.org,
mcascell@redhat.com, zhenwei pi <zhenwei.pi@linux.dev>
Subject: [PATCH 1/2] hw/virtio/virtio-crypto: verify asym request size
Date: Sun, 14 Dec 2025 17:09:38 +0800 [thread overview]
Message-ID: <20251214090939.408436-2-zhenwei.pi@linux.dev> (raw)
In-Reply-To: <20251214090939.408436-1-zhenwei.pi@linux.dev>
The total lenght of request is limited by cryptodev config, verify it
to avoid unexpected request from guest.
Fixes: 0e660a6f90a ("crypto: Introduce RSA algorithm")
Reported-by: AM 이재영 <nakamurajames123@gmail.com>
Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev>
---
hw/virtio/virtio-crypto.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 517f2089c5..94dbf9d92d 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -767,11 +767,18 @@ virtio_crypto_handle_asym_req(VirtIOCrypto *vcrypto,
uint32_t len;
uint8_t *src = NULL;
uint8_t *dst = NULL;
+ uint64_t max_len;
asym_op_info = g_new0(CryptoDevBackendAsymOpInfo, 1);
src_len = ldl_le_p(&req->para.src_data_len);
dst_len = ldl_le_p(&req->para.dst_data_len);
+ max_len = src_len + dst_len;
+ if (unlikely(max_len > vcrypto->conf.max_size)) {
+ virtio_error(vdev, "virtio-crypto asym too big length");
+ goto err;
+ }
+
if (src_len > 0) {
src = g_malloc0(src_len);
len = iov_to_buf(iov, out_num, 0, src, src_len);
--
2.43.0
next prev parent reply other threads:[~2025-12-14 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-14 9:09 [PATCH 0/2] Avoid QEMU OOM on huge request from guest zhenwei pi
2025-12-14 9:09 ` zhenwei pi [this message]
2025-12-14 9:09 ` [PATCH 2/2] cryptodev-builtin: Limit the maximum size zhenwei pi
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=20251214090939.408436-2-zhenwei.pi@linux.dev \
--to=zhenwei.pi@linux.dev \
--cc=arei.gonglei@huawei.com \
--cc=mcascell@redhat.com \
--cc=mst@redhat.com \
--cc=nakamurajames123@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-security@nongnu.org \
/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).