[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 17/55] vhost-backend: avoid overflow on memslots_limit
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 17/55] vhost-backend: avoid overflow on memslots_limit |
Date: |
Fri, 7 Jan 2022 20:04:24 -0500 |
From: Roman Kagan <rvkagan@yandex-team.ru>
Fix the (hypothetical) potential problem when the value parsed out of
the vhost module parameter in sysfs overflows the return value from
vhost_kernel_memslots_limit.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Message-Id: <20211111153354.18807-6-rvkagan@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-backend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index b65f8f7e97..44f7dbb243 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -58,7 +58,7 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev)
if (g_file_get_contents("/sys/module/vhost/parameters/max_mem_regions",
&s, NULL, NULL)) {
uint64_t val = g_ascii_strtoull(s, NULL, 10);
- if (!((val == G_MAXUINT64 || !val) && errno)) {
+ if (val < INT_MAX && val > 0) {
g_free(s);
return val;
}
--
MST
- Re: [PULL v3 12/55] virtio-pci: add support for configure interrupt, (continued)
Re: [PULL v3 12/55] virtio-pci: add support for configure interrupt, Cédric Le Goater, 2022/01/09
[PULL v3 13/55] trace-events,pci: unify trace events format, Michael S. Tsirkin, 2022/01/07
[PULL v3 14/55] vhost-user-blk: reconnect on any error during realize, Michael S. Tsirkin, 2022/01/07
[PULL v3 15/55] chardev/char-socket: tcp_chr_recv: don't clobber errno, Michael S. Tsirkin, 2022/01/07
[PULL v3 16/55] chardev/char-socket: tcp_chr_sync_read: don't clobber errno, Michael S. Tsirkin, 2022/01/07
[PULL v3 17/55] vhost-backend: avoid overflow on memslots_limit,
Michael S. Tsirkin <=
[PULL v3 18/55] vhost-backend: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
[PULL v3 20/55] vhost-user: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
[PULL v3 19/55] vhost-vdpa: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
[PULL v3 22/55] vhost-user-blk: propagate error return from generic vhost, Michael S. Tsirkin, 2022/01/07
[PULL v3 21/55] vhost: stick to -errno error return convention, Michael S. Tsirkin, 2022/01/07
[PULL v3 24/55] pcie_aer: Don't trigger a LSI if none are defined, Michael S. Tsirkin, 2022/01/07
[PULL v3 23/55] pci: Export the pci_intx() function, Michael S. Tsirkin, 2022/01/07
[PULL v3 26/55] hw/smbios: Use qapi for SmbiosEntryPointType, Michael S. Tsirkin, 2022/01/07
[PULL v3 25/55] smbios: Rename SMBIOS_ENTRY_POINT_* enums, Michael S. Tsirkin, 2022/01/07
[PULL v3 27/55] hw/i386: expose a "smbios-entry-point-type" PC machine property, Michael S. Tsirkin, 2022/01/07