Skip to content

xen/gntdev: reset the copy batch's writeable flag - #81

Merged
kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-194-gntdev-batch-writeable
Nov 4, 2026
Merged

kdaula merged 1 commit into
edera/mainlinefrom
kavi/cor-194-gntdev-batch-writeable

Conversation

@kdaula

@kdaula kdaula commented Nov 3, 2026 •

Copy link
Copy Markdown

UBSAN reports an invalid bool load in gntdev_put_pages() when a grant copy fails on its first segment.

gntdev_ioctl_grant_copy() resets nr_ops and nr_pages on the batch it takes, but not writeable, and a batch fresh from kmalloc() holds whatever was in that memory. If the first segment fails before gntdev_grant_copy_seg() sets writeable, the error path reads the uninitialised value. No pages are pinned at that point, so nothing is unpinned with the wrong flag. This resets writeable with the counters. Upstream master has the same code.

Tested by fuzzing /dev/xen/gntdev ioctls in a UBSAN dom0 and domU under Xen: with this applied the invalid-load report no longer appears.

COR-194

gntdev_ioctl_grant_copy() resets nr_ops and nr_pages on the batch it
takes but not writeable, and a batch fresh from kmalloc() holds whatever
was in that memory. If the first segment fails before
gntdev_grant_copy_seg() sets writeable, gntdev_put_pages() loads the
uninitialised bool, which UBSAN reports as an invalid load. No pages are
pinned at that point, so nothing is unpinned with the wrong flag.

Reset writeable with the counters.

Signed-off-by: Kavi <kavi@edera.dev>
@kdaula
kdaula marked this pull request as ready for review November 4, 2026 01:51
@kdaula
kdaula merged commit e79780b into edera/mainline Nov 4, 2026
3 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Backport to edera/6.18-lts: waiting

Waiting: earlier Edera commits on edera/mainline that touch the same files are not on edera/6.18-lts yet, and have to be backported first:

This is retried when a backport lands on edera/6.18-lts, and nightly. If one of them should never be backported, label its pull request no-backport, or list its subject in .automation/backport-skip on edera/6.18-lts.

Run log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants