From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken CC Subject: [PATCH 3/3] Check pci slot number in parse_pci_devfn Date: Tue, 24 Aug 2010 14:34:28 +0800 Message-ID: <20100824063428.GC10815@kt> References: <20100824062517.12408.45246.stgit@k1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: yamahata@valinux.co.jp, qemu-devel@nongnu.org To: kvm@vger.kernel.org Return-path: Received: from mail-qw0-f46.google.com ([209.85.216.46]:38558 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751953Ab0HXGec (ORCPT ); Tue, 24 Aug 2010 02:34:32 -0400 Received: by qwh6 with SMTP id 6so5789171qwh.19 for ; Mon, 23 Aug 2010 23:34:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20100824062517.12408.45246.stgit@k1> Sender: kvm-owner@vger.kernel.org List-ID: Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line is bigger than 0x1f, return error -EINVAL. 0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1) Signed-off-by: Ken CC --- hw/qdev-properties.c | 2 ++ hw/qdev.h | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 9219cd7..96d814c 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str) return -EINVAL; } } + if (slot > MAX_PCI_SLOTS) + return -EINVAL; if (str[n] != '\0') return -EINVAL; if (fn > 7) diff --git a/hw/qdev.h b/hw/qdev.h index 678f8b7..fcfe52e 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -7,6 +7,9 @@ #include "qemu-char.h" #include "qemu-option.h" + +#define MAX_PCI_SLOTS 0x1f + typedef struct Property Property; typedef struct PropertyInfo PropertyInfo; From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36079 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Onn5d-0007WO-7h for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Onn5c-000317-4R for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:34:33 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:43540) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Onn5c-000312-0z for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:34:32 -0400 Received: by qwh5 with SMTP id 5so5941508qwh.4 for ; Mon, 23 Aug 2010 23:34:31 -0700 (PDT) Date: Tue, 24 Aug 2010 14:34:28 +0800 From: Ken CC Message-ID: <20100824063428.GC10815@kt> References: <20100824062517.12408.45246.stgit@k1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100824062517.12408.45246.stgit@k1> Subject: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvm@vger.kernel.org Cc: yamahata@valinux.co.jp, qemu-devel@nongnu.org Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line is bigger than 0x1f, return error -EINVAL. 0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1) Signed-off-by: Ken CC --- hw/qdev-properties.c | 2 ++ hw/qdev.h | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 9219cd7..96d814c 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str) return -EINVAL; } } + if (slot > MAX_PCI_SLOTS) + return -EINVAL; if (str[n] != '\0') return -EINVAL; if (fn > 7) diff --git a/hw/qdev.h b/hw/qdev.h index 678f8b7..fcfe52e 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -7,6 +7,9 @@ #include "qemu-char.h" #include "qemu-option.h" + +#define MAX_PCI_SLOTS 0x1f + typedef struct Property Property; typedef struct PropertyInfo PropertyInfo;