From lyndon@orthanc.ab.ca  Fri Dec  1 14:11:44 2000
Return-Path: <lyndon@orthanc.ab.ca>
Received: from orthanc.ab.ca (207-167-15-66.dsl.worldgate.ca [207.167.15.66])
	by hub.freebsd.org (Postfix) with ESMTP id 7679537B400
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Dec 2000 14:11:44 -0800 (PST)
Received: (from lyndon@localhost)
	by orthanc.ab.ca (8.11.1/8.11.0.Beta3) id eB1MBcX32861;
	Fri, 1 Dec 2000 15:11:38 -0700 (MST)
Message-Id: <200012012211.eB1MBcX32861@orthanc.ab.ca>
Date: Fri, 1 Dec 2000 15:11:38 -0700 (MST)
From: Lyndon Nerenberg <lyndon@orthanc.ab.ca>
Reply-To: lyndon@orthanc.ab.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] PCIOCGETCONF requires write permissions
X-Send-Pr-Version: 3.2

>Number:         23216
>Category:       kern
>Synopsis:       [PATCH] PCIOCGETCONF ioctl requires write permissions
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 01 14:20:00 PST 2000
>Closed-Date:    Mon Apr 16 11:26:02 PDT 2001
>Last-Modified:  Mon Apr 16 11:26:21 PDT 2001
>Originator:     Lyndon Nerenberg
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
The Frobozz Magic Homing Pigeon Company
>Environment:

>Description:

/sys/pci/pci.c:pci_ioctl() fails all ioctl operations unless the caller
has /dev/pci opened for write. This causes 'pciconf -l' to fail when
run as a non-superuser. (A patch to pciconf to open /dev/pci read
only in the -l case follows in another pr.)

>How-To-Repeat:

Issue a PCIOCGETCONF request with /dev/pci opened read only.

>Fix:

Index: pci.c
===================================================================
RCS file: /home/ncvs/src/sys/pci/pci.c,v
retrieving revision 1.141.2.4
diff -u -u -r1.141.2.4 pci.c
--- pci.c       2000/10/28 23:10:17     1.141.2.4
+++ pci.c       2000/12/01 22:04:29
@@ -552,10 +552,6 @@
        const char *name;
        int error;
 
-       if (!(flag & FWRITE))
-               return EPERM;
-
-
        switch(cmd) {
        case PCIOCGETCONF:
                {
@@ -787,6 +783,9 @@
                break;
                }
        case PCIOCREAD:
+               if (!(flag & FWRITE))
+                       return EPERM;
+
                io = (struct pci_io *)data;
                switch(io->pi_width) {
                        pcicfgregs probe;
@@ -808,6 +807,9 @@
                break;
 
        case PCIOCWRITE:
+               if (!(flag & FWRITE))
+                       return EPERM;
+
                io = (struct pci_io *)data;
                switch(io->pi_width) {
                        pcicfgregs probe;


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bmah 
State-Changed-When: Mon Apr 16 11:26:02 PDT 2001 
State-Changed-Why:  
Closed by submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23216 
>Unformatted:
