Article View: muc.lists.freebsd.bugs
Article #532[Bug 300888] xen/gntdev: IOCTL_GNTDEV_SET_UNMAP_NOTIFY returns EINVAL for the first grant mapping (range check overflows)
From: bugzilla-noreply
Date: Thu, 19 Nov 2026 05:42
Date: Thu, 19 Nov 2026 05:42
75 lines
4915 bytes
4915 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300888
Bug ID: 300888
Summary: xen/gntdev: IOCTL_GNTDEV_SET_UNMAP_NOTIFY returns
EINVAL for the first grant mapping (range check
overflows)
Product: Base System
Version: 15.1-RELEASE
Hardware: amd64
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: sablomenkamp@gmail.com
Environment: FreeBSD 15.1-RELEASE amd64 as a PVH domU on Xen 4.20.5-pre (Debian
13 dom0), and as an HVM domU on Qubes OS 4.3 (Xen 4.19). Found while running
Xen's libxenvchan and the Qubes OS qrexec agent. Still present in main 5151bc2
(line numbers below are from that commit).
gntdev hands out file offsets from the top of the 64-bit offset space
downwards. The per-user free list starts as one region at offset 0 with
MAX_OFFSET_COUNT pages, and get_file_offset() takes pages from its end. So the
first IOCTL_GNTDEV_MAP_GRANT_REF on a freshly opened /dev/xen/gntdev returns
index 0xfffffffffffff000 for a one-page mapping.
gntdev_set_unmap_notify() (sys/dev/xen/gntdev/gntdev.c, line 909) then searches
the map tree with:
if (arg->index >= gmap->file_index &&
arg->index < gmap->file_index + gmap->count * PAGE_SIZE) {
For the topmost region, gmap->file_index + gmap->count * PAGE_SIZE wraps to 0.
The second test is then never true, and the ioctl returns EINVAL for both
UNMAP_NOTIFY_CLEAR_BYTE and UNMAP_NOTIFY_SEND_EVENT.
Xen's libxenvchan client makes exactly this call as its first mapping
(libxenvchan_client_init -> init_gnt_cli -> xengnttab_map_grant_ref_notify). As
a result, a FreeBSD domain can never be the client side of a vchan.
libxengnttab then reports "ioctl SET_UNMAP_NOTIFY failed: Invalid argument",
followed by a misleading "mmap failed".
To reproduce, with Xen 4.20 libxenvchan's vchan-socket-proxy:
- dom0: vchan-socket-proxy -m server <domid> /local/domain/0/data/test -
- FreeBSD domU: vchan-socket-proxy -m client 0 /local/domain/0/data/test -
The domU side fails. The reverse direction (domU as server) works.
Suggested fix: compare by subtraction, as the pager already does
(gmap->notify->index - gmap->file_index). The gntalloc branch of the same
function looks the index up by exact match and is not affected. Tested on
15.1-RELEASE GENERIC with only this change: 4 MiB passed through vchan with a
matching SHA-256, and the reply path worked. A tested patch against main is
available if wanted.
Disclosure: found and analysed with an AI assistant (Claude). The reproduction,
the test runs and the results are from my own machines.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-300888-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 300888] xen/gntdev: IOCTL_GNTDEV_SET_UNMAP_NOTIFY returns EINVAL for the first grant mapping (range check overflows) Date: Thu, 19 Nov 2026 05:42:15 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-300888-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="2035"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795066935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vIs4ZKsXkdmXvPbXaB3O5CrefPnBGJgcVAB5uwiAqWM=; b=Kv701TjCTO8FzhkpH+xnsQ+KbmRYX4E59w2hrDybPfhZjcRMszFXinAasYw58P0aaP7VWs XLvtw65aO/lLDhQUDA7Sh8zDK7qoF4zKG6MD1OcuLR8TcLNMTv2ljljqlFh9UjThFSuEQj KH0klcy/7/hFxKrOaiHkKrqYauPxMTUhJtGWTHzWpZMeax3FTDU8YvDG1MfQTkFy4/+0V9 fdrZl6HtZVK/BulsBHWTcvH5xn1/f938tR7DYyRkJUcPaJQXaFWdbzaYgo25zloZZ3fcTJ U7q2mm6F+NvQ7dLwlyp/7ExSWIF7BB8vieJpMrFejr8bmp3iOuG44oe4p0D4tQ== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes