Thread View: muc.lists.freebsd.bugs
1 messages
1 total messages
Started by bugzilla-noreply
Thu, 19 Nov 2026 05:42
[Bug 300888] xen/gntdev: IOCTL_GNTDEV_SET_UNMAP_NOTIFY returns EINVAL for the first grant mapping (range check overflows)
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads