From patchwork Thu Aug 22 11:37:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 269026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 01CD92C00C0 for ; Thu, 22 Aug 2013 21:38:23 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753061Ab3HVLiW (ORCPT ); Thu, 22 Aug 2013 07:38:22 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:40233 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057Ab3HVLiV (ORCPT ); Thu, 22 Aug 2013 07:38:21 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Aug 2013 21:29:52 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Aug 2013 21:29:51 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id CF4523578050 for ; Thu, 22 Aug 2013 21:38:11 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7MBMC4c43778120 for ; Thu, 22 Aug 2013 21:22:12 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7MBcAaQ012706 for ; Thu, 22 Aug 2013 21:38:11 +1000 Received: from skywalker.in.ibm.com ([9.79.217.96]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r7MBc8xF012676; Thu, 22 Aug 2013 21:38:09 +1000 From: "Aneesh Kumar K.V" To: benh@kernel.crashing.org, paulus@samba.org, agraf@suse.de Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, "Aneesh Kumar K.V" Subject: [PATCH] powerpc/kvm: Handle the boundary condition correctly Date: Thu, 22 Aug 2013 17:07:59 +0530 Message-Id: <1377171479-25738-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.2 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13082211-7014-0000-0000-0000037FC53E Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: 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;