From patchwork Fri Oct 2 19:09:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 525739 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 0AFA81402D5 for ; Sat, 3 Oct 2015 05:29:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=JGeyhiwj; dkim-atps=neutral Received: from localhost ([::1]:34630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi60y-00081J-OV for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2015 15:29:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5ii-0007Yu-5q for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi5ih-00079y-Bx for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:16 -0400 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:33081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi5ih-00079S-68 for qemu-devel@nongnu.org; Fri, 02 Oct 2015 15:10:15 -0400 Received: by wiclk2 with SMTP id lk2so46705686wic.0 for ; Fri, 02 Oct 2015 12:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Eq9tAVRXPAhmQQuOkl7Tg7fnPz5lcOikZLHC4YapDMs=; b=JGeyhiwjU53Gv14p770rhUBZkAahFJX+lSxo5okjfUCsFft5Q6QQbw4RSFmhbCNz7+ 7DK0ijuJ1azxHn9WepTw186v/gTCgkRca27WSx1KQM8n4qyKqyUsPu+UP5TSZk4xCXXi jP9oFZb4Ai88Z/qUZb03nVLMbuhqznnTn8YAcDBGkQu0lPoIAoJhcvT/t3TwvgRmBBPw Yf2K2Ysf7XvY6Paa9giDqCVZCXCESWFQcN1Ft1eGh4CWsuB2+rxgDXm8Evz39yQBeofv NyMn1yg1WrHjZtHmakVAbK57p4HrTnOk5Yk1ZR686seOCPY6p2/P4P6tvtLuVoVv+erz 37LQ== X-Received: by 10.180.102.226 with SMTP id fr2mr489814wib.3.1443813014611; Fri, 02 Oct 2015 12:10:14 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id lb10sm12738802wjc.9.2015.10.02.12.10.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 12:10:13 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 2 Oct 2015 21:09:14 +0200 Message-Id: <1443812991-17356-12-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443812991-17356-1-git-send-email-marcandre.lureau@redhat.com> References: <1443812991-17356-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::234 Cc: drjones@redhat.com, claudio.fontana@huawei.com, stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , pbonzini@redhat.com, cam@cs.ualberta.ca Subject: [Qemu-devel] [PATCH v5 11/48] ivshmem: limit maximum number of peers to G_MAXUINT16 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 From: Marc-André Lureau Limit the maximum number of peers to MAXUINT16. This is more realistic and better matches the limit of the doorbell register. Signed-off-by: Marc-André Lureau Reviewed-by: Claudio Fontana --- hw/misc/ivshmem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index e7224b9..3787398 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -34,6 +34,7 @@ #define PCI_VENDOR_ID_IVSHMEM PCI_VENDOR_ID_REDHAT_QUMRANET #define PCI_DEVICE_ID_IVSHMEM 0x1110 +#define IVSHMEM_MAX_PEERS G_MAXUINT16 #define IVSHMEM_IOEVENTFD 0 #define IVSHMEM_MSI 1 @@ -421,8 +422,8 @@ static int increase_dynamic_storage(IVShmemState *s, int new_min_size) int j, old_nb_alloc; - /* check for integer overflow */ - if (new_min_size >= INT_MAX / sizeof(Peer) - 1 || new_min_size <= 0) { + /* limit number of max peers */ + if (new_min_size <= 0 || new_min_size > IVSHMEM_MAX_PEERS) { return -1; }