Repository navigation
xen/gntdev: reset the copy batch's writeable flag - #81
Merged
Merged
Conversation
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
marked this pull request as ready for review
November 4, 2026 01:51
azenla
approved these changes
Nov 4, 2026
|
Backport to Waiting: earlier Edera commits on
This is retried when a backport lands on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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