From patchwork Mon Jun 8 13:00:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 28623 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n58D18sp022340 for ; Mon, 8 Jun 2009 13:01:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754726AbZFHNAS (ORCPT ); Mon, 8 Jun 2009 09:00:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754402AbZFHNAR (ORCPT ); Mon, 8 Jun 2009 09:00:17 -0400 Received: from mx2.redhat.com ([66.187.237.31]:54667 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754692AbZFHNAL (ORCPT ); Mon, 8 Jun 2009 09:00:11 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n58D0EBc006565 for ; Mon, 8 Jun 2009 09:00:14 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n58D0Ccw011474; Mon, 8 Jun 2009 09:00:12 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n58D0BA5022985; Mon, 8 Jun 2009 09:00:11 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 1182C250AC1; Mon, 8 Jun 2009 16:00:11 +0300 (IDT) From: Avi Kivity To: kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [PATCH 2/2] KVM: Prevent overflow in largepages calculation Date: Mon, 8 Jun 2009 16:00:10 +0300 Message-Id: <1244466010-24909-3-git-send-email-avi@redhat.com> In-Reply-To: <1244466010-24909-1-git-send-email-avi@redhat.com> References: <1244466010-24909-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If userspace specifies a memory slot that is larger than 8 petabytes, it could overflow the largepages variable. Signed-off-by: Avi Kivity --- virt/kvm/kvm_main.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index b9ca73c..669eb4a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1087,8 +1087,7 @@ int __kvm_set_memory_region(struct kvm *kvm, int r; gfn_t base_gfn; unsigned long npages, ugfn; - int largepages; - unsigned long i; + unsigned long largepages, i; struct kvm_memory_slot *memslot; struct kvm_memory_slot old, new;