From owner-freebsd-arch@FreeBSD.ORG Mon Jun 16 12:49:09 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 55E9337B401; Mon, 16 Jun 2003 12:49:09 -0700 (PDT) Received: from mail.cyberonic.com (mail.cyberonic.com [4.17.179.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F0E543F93; Mon, 16 Jun 2003 12:49:08 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (node-40244c0a.sfo.onnet.us.uu.net [64.36.76.10]) by mail.cyberonic.com (8.12.8/8.12.5) with ESMTP id h5GKEhMo026526; Mon, 16 Jun 2003 16:14:44 -0400 Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.9/8.11.6) id h5GJnZg0012436; Mon, 16 Jun 2003 12:49:35 -0700 (PDT) (envelope-from jmg) Date: Mon, 16 Jun 2003 12:49:35 -0700 From: John-Mark Gurney To: Robert Watson Message-ID: <20030616194935.GR73854@funkthat.com> Mail-Followup-To: Robert Watson , arch@freebsd.org References: <20030616074122.GF73854@funkthat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: arch@freebsd.org Subject: Re: make /dev/pci really readable X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2003 19:49:09 -0000 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Robert Watson wrote this message on Mon, Jun 16, 2003 at 13:54 -0400: > On Mon, 16 Jun 2003, John-Mark Gurney wrote: > will affect all users in the system). Could you do that cleanup in the > first pass, then revisit the permissions change? ok, I've taken a look at it, and I don't see any major problems with it besides what I mentioned earlier. I've attached a patch that only lets you do pciconf -l (query pci devices we know about), but it also enforces the register to be in valid bounds and also makes sure it's aligned. I think it's safest to do it here. Should I copy the restrictions on read into the write block (actually, take them out of the case so they can be shared)? -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pci_user.patch" Index: pci_user.c =================================================================== RCS file: /home/ncvs/src/sys/dev/pci/pci_user.c,v retrieving revision 1.9 diff -u -r1.9 pci_user.c --- pci_user.c 2003/03/03 12:15:44 1.9 +++ pci_user.c 2003/06/16 19:44:39 @@ -176,7 +176,7 @@ const char *name; int error; - if (!(flag & FWRITE)) + if (!(flag & FWRITE) && cmd != PCIOCGETCONF) return EPERM; @@ -342,7 +342,7 @@ for (cio->num_matches = 0, error = 0, i = 0, dinfo = STAILQ_FIRST(devlist_head); (dinfo != NULL) && (cio->num_matches < ionum) - && (error == 0) && (i < pci_numdevs); + && (error == 0) && (i < pci_numdevs) && (dinfo != NULL); dinfo = STAILQ_NEXT(dinfo, pci_links), i++) { if (i < cio->offset) @@ -412,7 +412,10 @@ } case PCIOCREAD: io = (struct pci_io *)data; - switch(io->pi_width) { + if (io->pi_reg < 0 || io->pi_reg + io_pi_width > PCI_REGMAX || + io->pi_reg & (io->pi_width - 1)) + error = EINVAL; + else switch(io->pi_width) { case 4: case 2: case 1: @@ -439,7 +442,7 @@ } break; default: - error = ENODEV; + error = EINVAL; break; } break; --FL5UXtIhxfXey3p5--