From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Date: Thu, 22 Aug 2013 11:49:59 +0000 Subject: [PATCH] powerpc/kvm: Handle the boundary condition correctly Message-Id: <1377171479-25738-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: benh@kernel.crashing.org, paulus@samba.org, agraf@suse.de Cc: linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" , kvm-ppc@vger.kernel.org From: "Aneesh Kumar K.V" We should be able to copy upto count bytes Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 710d313..0ae6bb6 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1362,7 +1362,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf, lbuf = (unsigned long __user *)buf; nb = 0; - while (nb + sizeof(hdr) + HPTE_SIZE < count) { + while (nb + sizeof(hdr) + HPTE_SIZE <= count) { /* Initialize header */ hptr = (struct kvm_get_htab_header __user *)buf; hdr.n_valid = 0; @@ -1385,7 +1385,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf, /* Grab a series of valid entries */ while (i < kvm->arch.hpt_npte && hdr.n_valid < 0xffff && - nb + HPTE_SIZE < count && + nb + HPTE_SIZE <= count && record_hpte(flags, hptp, hpte, revp, 1, first_pass)) { /* valid entry, write it out */ ++hdr.n_valid; -- 1.8.1.2