From: Sami Uddin sami.md.ko@gmail.com
To: mst@redhat.com
Cc: jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, Sami Uddin <sami.md.ko@gmail.com>
Subject: [PATCH v2] virtio: reject shm region if length is zero
Date: Sun, 11 May 2025 21:14:28 +0930 [thread overview]
Message-ID: <20250511114428.2061-1-sami.md.ko@gmail.com> (raw)
From: Sami Uddin <sami.md.ko@gmail.com>
Prevent usage of shared memory regions where the length is zero,
as such configurations are not valid and may lead to unexpected behavior.
Signed-off-by: Sami Uddin <sami.md.ko@gmail.com>
---
v2:
- Fixed coding style issue: added space after 'if' statement
include/linux/virtio_config.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 169c7d367fac..b641b16d42ef 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -329,6 +329,8 @@ static inline
bool virtio_get_shm_region(struct virtio_device *vdev,
struct virtio_shm_region *region, u8 id)
{
+ if (region->len == 0)
+ return false;
if (!vdev->config->get_shm_region)
return false;
return vdev->config->get_shm_region(vdev, region, id);
--
2.34.1
next reply other threads:[~2025-05-11 11:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-11 11:44 Sami [this message]
2025-05-11 15:36 ` [PATCH v2] virtio: reject shm region if length is zero Michael S. Tsirkin
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=20250511114428.2061-1-sami.md.ko@gmail.com \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sami.md.ko@gmail.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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