KVM: Write the per-page "segment" when clearing (part of) a guest page
authorSean Christopherson <seanjc@google.com>
Thu, 29 Aug 2024 19:14:12 +0000 (12:14 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:15:34 +0000 (20:15 -0700)
commitec495f2ab12290b008a691e826b39b895f458945
tree5ffae0a5d55f26221708cb9bd57ab28b10447b30
parente027ba1b83ad017a56c108eea2f42eb9f8ae5204
KVM: Write the per-page "segment" when clearing (part of) a guest page

Pass "seg" instead of "len" when writing guest memory in kvm_clear_guest(),
as "seg" holds the number of bytes to write for the current page, while
"len" holds the total bytes remaining.

Luckily, all users of kvm_clear_guest() are guaranteed to not cross a page
boundary, and so the bug is unhittable in the current code base.

Fixes: 2f5414423ef5 ("KVM: remove kvm_clear_guest_page")
Reported-by: zyr_ms@outlook.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219104
Link: https://lore.kernel.org/r/20240829191413.900740-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/kvm_main.c