Article View: muc.lists.freebsd.bugs
Article #533[Bug 300889] xen/gntdev: SET_UNMAP_NOTIFY allocates sizeof(*arg) (16 bytes) for a struct notify_data (24 bytes), heap overflow
From: bugzilla-noreply
Date: Thu, 19 Nov 2026 05:48
Date: Thu, 19 Nov 2026 05:48
59 lines
4067 bytes
4067 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300889
Bug ID: 300889
Summary: xen/gntdev: SET_UNMAP_NOTIFY allocates sizeof(*arg)
(16 bytes) for a struct notify_data (24 bytes), heap
overflow
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).
In gntdev_set_unmap_notify() (sys/dev/xen/gntdev/gntdev.c, lines 900 and 911),
both gref->notify and gmap->notify are allocated with malloc(sizeof(*arg),
...). That is struct ioctl_gntdev_unmap_notify, 16 bytes on amd64. The buffer
then holds a struct notify_data, 24 bytes, which adds notify_evtchn_handle.
copy_notify_helper() writes the handle 8 bytes past the end of the allocation.
Any user who can open /dev/xen/gntdev can trigger it.
How it showed: under qrexec load (hundreds of vchan connections, each using
SET_UNMAP_NOTIFY), a general protection fault in notify(). The register that
should have held the handle contained ASCII text, because the neighbouring
allocation had been overwritten.
Suggested fix: allocate sizeof(struct notify_data) (M_WAITOK | M_ZERO) in both
places. A tested patch against main is available if wanted.
The bug in the previous report is probably why this path was rarely reached
before.
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-300889-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 300889] xen/gntdev: SET_UNMAP_NOTIFY allocates sizeof(*arg) (16 bytes) for a struct notify_data (24 bytes), heap overflow Date: Thu, 19 Nov 2026 05:48:05 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-300889-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="6184"; 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=1795067285; 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=NEkSsQGZdrLvcvHd4b2JaNQxyrRKI5g2TTFX/a8QYx0=; b=Yv1Van5c77wtJTBU8MttuA1VlBu/BnNsCcy3MgpzOb0NZJhFWyD9TeG3YnseAlIcTTs21W ITrkugdGw9s+N0oA6Z1LqZrq9+zUTMgYBRnjqRshOEZDPU2td19yf3ixXnIhRSKNeaMMP2 IrYzUYZjgvOBHH+I/v9HV4WhqDRXV+7enjyrutW4aF5UWEEqdFwrkmsk7/Rb/ybxtBSMKi inxoLv3IgTjkQXwNDLj9pHSKAFFvLDJTeui4/xk5oJBPrnlnSdNo6ZJOn3FdRRotO9K/Rj nBgSb8imoo816hUbbxgPSdjQEcpPHGp1Luqcd6xVTcDPQK75h3Y5K7D7zsV4pg== 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