From patchwork Mon Mar 21 22:00:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bandan Das X-Patchwork-Id: 600364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qTVCJ1GBWz9s2k for ; Tue, 22 Mar 2016 09:01:16 +1100 (AEDT) Received: from localhost ([::1]:60721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai7sv-0003P4-VI for incoming@patchwork.ozlabs.org; Mon, 21 Mar 2016 18:01:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai7sg-00038B-7U for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai7sb-0005ZI-7P for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai7sb-0005ZE-1o for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8EE8E6445E for ; Mon, 21 Mar 2016 22:00:51 +0000 (UTC) Received: from link.home (ovpn-113-213.phx2.redhat.com [10.3.113.213]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2LM0o5A030911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Mar 2016 18:00:50 -0400 From: Bandan Das To: qemu-devel , Alex Williamson Date: Mon, 21 Mar 2016 18:00:50 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 21 Mar 2016 22:00:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] vfio: add check for memory region overflow condition X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org vfio_listener_region_add for a iommu mr results in an overflow assert since emulated iommu memory region is initialized with UINT64_MAX. Add a check just like memory_region_size() does. Signed-off-by: Bandan Das --- hw/vfio/common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index fb588d8..269244b 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -349,7 +349,12 @@ static void vfio_listener_region_add(MemoryListener *listener, if (int128_ge(int128_make64(iova), llend)) { return; } - end = int128_get64(llend); + + if (int128_eq(llend, int128_2_64())) { + end = UINT64_MAX; + } else { + end = int128_get64(llend); + } if ((iova < container->min_iova) || ((end - 1) > container->max_iova)) { error_report("vfio: IOMMU container %p can't map guest IOVA region"