Xen Security Advisory 521 v2 (CVE-2026-102701) - tapdisk: Out-of-bounds access in tap_ctl_connect_xenblkif()

Xen.org security team posted 1 patch 1 month, 1 week ago
Xen Security Advisory 521 v2 (CVE-2026-102701) - tapdisk: Out-of-bounds access in tap_ctl_connect_xenblkif()
Posted by Xen.org security team 1 month, 1 week ago
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

           Xen Security Advisory CVE-2026-102701 / XSA-521
                              version 2

      tapdisk: Out-of-bounds access in tap_ctl_connect_xenblkif()

UPDATES IN VERSION 2
====================

Public release.

ISSUE DESCRIPTION
=================

Tapdisk is a userspace xen-blkback implementation used by the XAPI
toolstack.

During connection, multi-page rings may be negotiated between the
frontend and backend.  Tapdisk had no boundary check on the size
requested by the frontend, and assumed it did not exceed 8.

IMPACT
======

A buggy or malicious guest can cause a stack overflow in tapdisk,
potentially leading to code execution.  Tapdisk normally runs as root.

VULNERABLE SYSTEMS
==================

All versions of tapdisk are vulnerable.

MITIGATION
==========

There are no mitigations.

CREDITS
=======

This issue was discovered by Claude Opus and diagnosed as a security issue
by Teddy Astie of Vates.

RESOLUTION
==========

Applying the attached patch resolves this issue.

xsa521.patch           blktap master

$ sha256sum xsa521*
72ece150e9d0836f217f3382c8dc76cd51bffbe4b7610c00f219b90e5600cbc5  xsa521.patch
$

DEPLOYMENT DURING EMBARGO
=========================

Deployment of the patches and/or mitigations described above (or
others which are substantially similar) is permitted during the
embargo, even on public-facing systems with untrusted guest users and
administrators.

But: Distribution of updated software is prohibited (except to other
members of the predisclosure list).

Predisclosure list members who wish to deploy significantly different
patches and/or mitigations, please contact the Xen Project Security
Team.


(Note: this during-embargo deployment notice is retained in
post-embargo publicly released Xen Project advisories, even though it
is then no longer applicable.  This is to enable the community to have
oversight of the Xen Project Security Team's decisionmaking.)

For more information about permissible uses of embargoed information,
consult the Xen Project community's agreed Security Policy:
  http://www.xenproject.org/security-policy.html
-----BEGIN PGP SIGNATURE-----

iQFABAEBCAAqFiEEI+MiLBRfRHX6gGCng/4UyVfoK9kFAmrOIvgMHHBncEB4ZW4u
b3JnAAoJEIP+FMlX6CvZgdgIAKXTyop/90HNxeBpRVbYP2vrPCm2YBMzoc3YtxdM
0wWdbFvUptHWnzypCWuUGJWq8ZFf4lInnkJrj0sJ9te+OSQDqcfwTMEQuDWzBM08
lQ27H0kcum3rble2V2CFCK4uOoLYwOYX/bA5vCeGiiPQcUU3m++6IoAMaRY7G2V7
RTNJmNCtbGiC7l3ExUX9KxnFCSaX9gL99YkygybBecSsjJhdlGZj7pzvJtomv1sC
fVSAFmXkivLGKX8TXQdj/48xmdqNSIQgYbdSdyZgGjmy7bxIgxB576FHwlN/fzf7
ZzpeEO8yZTFWeCJCKZavvjsq/7u2vxUtpoL3c81vSKWCOLc=
=w1aW
-----END PGP SIGNATURE-----
From: Teddy Astie <teddy.astie@vates.tech>
Subject: Ensure passed ring-page-order is valid

The current logic accepts any guest provided ring order, which can cause a
stack overflow in tap_ctl_connect_xenblkif() as tapdisk_message_blkif::gref
can only store 8 grant references, yet order may be larger than 3.

Fix this by checking that ring order values is in [0..3] range.  Also clarify
the gref array size in tapdisk_message_blkif (fixes TODO).

This is XSA-521 / CVE-2026-102701.

Signed-off-by: Teddy Astie <teddy.astie@vates.tech>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Tested-by: Alex Brett <alex.brett@citrix.com>

diff --git a/control/tap-ctl-xen.c b/control/tap-ctl-xen.c
index f09b76ea8255..37dff06623bf 100644
--- a/control/tap-ctl-xen.c
+++ b/control/tap-ctl-xen.c
@@ -45,6 +45,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "xen_blkif.h"
+#include "debug.h"
 #include "tap-ctl.h"
 #include "compiler.h"
 #include "util.h"
@@ -58,7 +60,9 @@ tap_ctl_connect_xenblkif(const pid_t pid, const domid_t domid, const int devid,
     tapdisk_message_t message;
     int i, err;
 
-	memset(&message, 0, sizeof(message));
+    ASSERT(order >= 0 && order <= MAX_RING_PAGE_ORDER);
+
+    memset(&message, 0, sizeof(message));
     message.type = TAPDISK_MESSAGE_XENBLKIF_CONNECT;
     message.cookie = minor;
 
diff --git a/include/tapdisk-message.h b/include/tapdisk-message.h
index 489017ca6909..7231a14d301c 100644
--- a/include/tapdisk-message.h
+++ b/include/tapdisk-message.h
@@ -34,6 +34,8 @@
 #include <inttypes.h>
 #include <sys/types.h>
 
+#include "xen_blkif.h"
+
 /*
  * TODO This is quite small since we don't allow path bigger than 256 chars. If
  * we ever increase this, make sure tapdisk_message_t structures are not
@@ -135,9 +137,8 @@ typedef struct tapdisk_message_blkif {
 
 	/**
 	 * Grant references for the shared ring.
-	 * TODO Why 8 specifically?
 	 */
-	uint32_t gref[8];
+	uint32_t gref[MAX_RING_PAGES];
 
 	/**
 	 * Number of pages in the ring, expressed as a page order.
diff --git a/tapback/frontend.c b/tapback/frontend.c
index 243f84252dd6..986f45647bf6 100644
--- a/tapback/frontend.c
+++ b/tapback/frontend.c
@@ -119,6 +119,12 @@ connect_tap(vbd_t * const device)
                 "%d", &order))
         order = 0;
 
+    if (order < 0 || order > MAX_RING_PAGE_ORDER) {
+        WARN(device, "front-end asked for an invalid ring order: %d\n", order);
+        err = EINVAL;
+        goto out;
+    }
+
      nr_pages = 1 << order;
 
     if (!(gref = calloc(nr_pages, sizeof(grant_ref_t)))) {