From 5f06a2f58ec42c270352576156e3f2d58e483b22 Mon Sep 17 00:00:00 2001 From: Liu Long Date: Tue, 31 May 2022 09:38:09 +0800 Subject: [PATCH] ACRN: DM: Fix the vsock Guest Cid overflow issue The vsock cid type is u64, redefine the cid type to u64, and use dm_strtoul API replace dm_strtoi. Tracked-On: #7456 Signed-off-by: Liu Long --- devicemodel/hw/pci/virtio/vhost_vsock.c | 5 +++-- devicemodel/include/vhost_vsock.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/devicemodel/hw/pci/virtio/vhost_vsock.c b/devicemodel/hw/pci/virtio/vhost_vsock.c index 06618d721..0f87f8fc8 100644 --- a/devicemodel/hw/pci/virtio/vhost_vsock.c +++ b/devicemodel/hw/pci/virtio/vhost_vsock.c @@ -238,7 +238,8 @@ static int virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) { struct virtio_vsock *vsock; - int rc, cid; + int rc; + uint64_t cid; pthread_mutexattr_t attr; char *devopts = NULL; char *tmp = NULL; @@ -254,7 +255,7 @@ virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) } if (!strncmp(tmp, "cid=", 4)) { strsep(&tmp, "="); - dm_strtoi(tmp, NULL, 10, &cid); + dm_strtoul(tmp, NULL, 10, &cid); } free(devopts); diff --git a/devicemodel/include/vhost_vsock.h b/devicemodel/include/vhost_vsock.h index 324a88218..178ffe2fe 100644 --- a/devicemodel/include/vhost_vsock.h +++ b/devicemodel/include/vhost_vsock.h @@ -29,7 +29,7 @@ (1ULL << VIRTIO_RING_F_EVENT_IDX) | (1ULL << VHOST_F_LOG_ALL) | \ (1ULL << VIRTIO_F_ANY_LAYOUT) | (1ULL << VIRTIO_F_VERSION_1) -#define U32_MAX 65535 +#define U32_MAX ((uint32_t)~0U) #define VMADDR_CID_HOST 2 struct virtio_vsock_config {