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:49:27 +0800 Message-ID: <20100824064927.GB11495@kt> References: <20100824063307.GA10815@kt> 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-qy0-f174.google.com ([209.85.216.174]:46918 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753935Ab0HXGtb (ORCPT ); Tue, 24 Aug 2010 02:49:31 -0400 Received: by qyk9 with SMTP id 9so3416780qyk.19 for ; Mon, 23 Aug 2010 23:49:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20100824063307.GA10815@kt> 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=45449 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnnKO-0002hF-AF for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:49:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnnK9-0004s4-Lw for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:49:34 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:47076) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnnK9-0004s0-IW for qemu-devel@nongnu.org; Tue, 24 Aug 2010 02:49:33 -0400 Received: by qwh5 with SMTP id 5so5948586qwh.4 for ; Mon, 23 Aug 2010 23:49:33 -0700 (PDT) Date: Tue, 24 Aug 2010 14:49:27 +0800 From: Ken CC Message-ID: <20100824064927.GB11495@kt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100824063307.GA10815@kt> 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;