Skip to content

Commit ec495f2

Browse files
committed
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: 2f54144 ("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>
1 parent e027ba1 commit ec495f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

virt/kvm/kvm_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3581,7 +3581,7 @@ int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
35813581
int ret;
35823582

35833583
while ((seg = next_segment(len, offset)) != 0) {
3584-
ret = kvm_write_guest_page(kvm, gfn, zero_page, offset, len);
3584+
ret = kvm_write_guest_page(kvm, gfn, zero_page, offset, seg);
35853585
if (ret < 0)
35863586
return ret;
35873587
offset = 0;

0 commit comments

Comments
 (0)