From: David Woodhouse The ring order is read from the guest-shared interface page into a signed int, so a large value became negative and bypassed the MAX_RING_ORDER check, leading to an undefined shift. Keep it unsigned. Treat any negative return from the event channel bind as failure, not just -1, and fail the connect if the frontend provides no 'tag' key rather than passing NULL into the fsdev layer. Fixes: b37eeb020123 ("xen/9pfs: introduce Xen 9pfs backend") Reported-by: Hui Peng Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4523 Signed-off-by: David Woodhouse --- hw/9pfs/xen-9p-backend.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 430de23fadb..6e26a445a09 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -453,7 +453,7 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev) xen_9pdev->rings = g_new0(Xen9pfsRing, xen_9pdev->num_rings); for (i = 0; i < xen_9pdev->num_rings; i++) { char *str; - int ring_order; + uint32_t ring_order; xen_9pdev->rings[i].priv = xen_9pdev; xen_9pdev->rings[i].evtchn = -1; @@ -515,7 +515,7 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev) (xen_9pdev->rings[i].evtchndev, xendev->dom, xen_9pdev->rings[i].evtchn); - if (xen_9pdev->rings[i].local_port == -1) { + if (xen_9pdev->rings[i].local_port < 0) { xen_pv_printf(xendev, 0, "xenevtchn_bind_interdomain failed port=%d\n", xen_9pdev->rings[i].evtchn); @@ -531,6 +531,9 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev) xen_9pdev->id = s->fsconf.fsdev_id = g_strdup_printf("xen9p%d", xendev->dev); xen_9pdev->tag = s->fsconf.tag = xenstore_read_fe_str(xendev, "tag"); + if (!xen_9pdev->tag) { + goto out; + } fsdev = qemu_opts_create(qemu_find_opts("fsdev"), s->fsconf.tag, 1, NULL); -- 2.43.0