public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@kernel.org
To: kvm@vger.kernel.org
Subject: [Bug 219104] New: A simple typo in kvm_main.c which will lead to erroneous memory access
Date: Mon, 29 Jul 2024 12:17:11 +0000	[thread overview]
Message-ID: <bug-219104-28872@https.bugzilla.kernel.org/> (raw)

https://bugzilla.kernel.org/show_bug.cgi?id=219104

            Bug ID: 219104
           Summary: A simple typo in kvm_main.c which will lead to
                    erroneous memory access
           Product: Virtualization
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: kvm
          Assignee: virtualization_kvm@kernel-bugs.osdl.org
          Reporter: zyr_ms@outlook.com
        Regression: No

It seems there is a rather simple typo in `virt/kvm/kvm_main.c` function
`kvm_clear_guest`.


// virt/kvm/kvm_main.c:#L3586
int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len)
{
        const void *zero_page = (const void *)
__va(page_to_phys(ZERO_PAGE(0)));
        gfn_t gfn = gpa >> PAGE_SHIFT;
        int seg;
        int offset = offset_in_page(gpa);
        int ret;

        while ((seg = next_segment(len, offset)) != 0) {
                ret = kvm_write_guest_page(kvm, gfn, zero_page, offset, len);
                if (ret < 0)
                        return ret;
                offset = 0;
                len -= seg;
                ++gfn;
        }
        return 0;
}


The arg `len` of `kvm_write_guest_page(kvm, gfn, zero_page, offset, len)`
should be `seg`. And this error will lead to clearing a lot of incorrect
memory.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

             reply	other threads:[~2024-07-29 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 12:17 bugzilla-daemon [this message]
2024-07-29 12:20 ` [Bug 219104] A simple typo in kvm_main.c which will lead to erroneous memory access bugzilla-daemon
2024-07-29 12:20 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-219104-28872@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox