From patchwork Thu May 13 01:29:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wright X-Patchwork-Id: 99204 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4D2U8lv005285 for ; Thu, 13 May 2010 02:30:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752351Ab0EMCaF (ORCPT ); Wed, 12 May 2010 22:30:05 -0400 Received: from sous-sol.org ([216.99.217.87]:42042 "EHLO sequoia.sous-sol.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751542Ab0EMCaE (ORCPT ); Wed, 12 May 2010 22:30:04 -0400 Received: from sequoia.sous-sol.org (sequoia.sous-sol.org [127.0.0.1]) by sequoia.sous-sol.org (8.14.3/8.14.3) with ESMTP id o4D1TvTV012472; Wed, 12 May 2010 18:29:57 -0700 Received: (from chrisw@localhost) by sequoia.sous-sol.org (8.14.3/8.14.3/Submit) id o4D1TvxM012471; Wed, 12 May 2010 18:29:57 -0700 Date: Wed, 12 May 2010 18:29:57 -0700 From: Chris Wright To: greg@kroah.com, jbarnes@virtuousgeek.org, matthew@wil.cx Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, ddutile@redhat.com, alex.williamson@redhat.com Subject: [PATCH 2/2] pci: allow sysfs file owner to read device dependent config space Message-ID: <20100513012957.GB28034@sequoia.sous-sol.org> References: <20100513012857.GA28034@sequoia.sous-sol.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100513012857.GA28034@sequoia.sous-sol.org> User-Agent: Mutt/1.5.20 (2009-08-17) X-Virus-Scanned: clamav-milter 0.95.3 at sequoia.sous-sol.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sequoia.sous-sol.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 13 May 2010 02:30:09 +0000 (UTC) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index ad44557..8a6fcc0 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -362,12 +363,13 @@ pci_read_config(struct file *filp, struct kobject *kobj, char *buf, loff_t off, size_t count) { struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); + struct inode *inode = filp->f_path.dentry->d_inode; unsigned int size = 64; loff_t init_off = off; u8 *data = (u8*) buf; /* Several chips lock up trying to read undefined config space */ - if (capable(CAP_SYS_ADMIN)) { + if (capable(CAP_SYS_ADMIN) || is_owner_or_cap(inode)) { size = dev->cfg_size; } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { size = 128;