From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751622AbbKJTDz (ORCPT ); Tue, 10 Nov 2015 14:03:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60606 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbbKJTDx (ORCPT ); Tue, 10 Nov 2015 14:03:53 -0500 Message-ID: <1447182232.4925.116.camel@redhat.com> Subject: Re: [patch v2] vfio/pci: make an array larger From: Alex Williamson To: Dan Carpenter Cc: "Sean O. Stalley" , Mark Rustad , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Tue, 10 Nov 2015 12:03:52 -0700 In-Reply-To: <20151109122455.GA28870@mwanda> References: <20151109122455.GA28870@mwanda> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2015-11-09 at 15:24 +0300, Dan Carpenter wrote: > Smatch complains about a possible out of bounds error: > > drivers/vfio/pci/vfio_pci_config.c:1241 vfio_cap_init() > error: buffer overflow 'pci_cap_length' 20 <= 20 > > The problem is that pci_cap_length[] was defined as large enough to > hold "PCI_CAP_ID_AF + 1" elements. The code in vfio_cap_init() assumes > it has PCI_CAP_ID_MAX + 1 elements. Originally, PCI_CAP_ID_AF and > PCI_CAP_ID_MAX were the same but then we introduced PCI_CAP_ID_EA in > f80b0ba95964 ('PCI: Add Enhanced Allocation register entries') so now > the array is too small. > > Let's fix this by making the array size PCI_CAP_ID_MAX + 1. And let's > make a similar change to pci_ext_cap_length[] for consistency. Also > both these arrays can be made const. > > Signed-off-by: Dan Carpenter > --- Applied to next for v4.4. Thanks! Alex