From owner-p4-projects@FreeBSD.ORG Mon Jun 5 15:21:23 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 63D0116A894; Mon, 5 Jun 2006 15:21:21 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 52F4C16A89F for ; Mon, 5 Jun 2006 15:21:18 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id F257543D45 for ; Mon, 5 Jun 2006 15:21:17 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k55FJXta097559 for ; Mon, 5 Jun 2006 15:19:33 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k55FJXNu097556 for perforce@freebsd.org; Mon, 5 Jun 2006 15:19:33 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 5 Jun 2006 15:19:33 GMT Message-Id: <200606051519.k55FJXNu097556@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 98567 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2006 15:21:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=98567 Change 98567 by rwatson@rwatson_zoo on 2006/06/05 15:19:11 Integrate TrustedBSD audit3 branch from TrustedBSD base to loop back audit work: - audit_submit.3 hooked up. - Audit additional VFS system call arguments. - Audit cleanup and per-audit pipe preselection. Also: - USB cleanup. Affected files ... .. //depot/projects/trustedbsd/audit3/lib/libbsm/Makefile#18 integrate .. //depot/projects/trustedbsd/audit3/sys/dev/usb/ugen.c#6 integrate .. //depot/projects/trustedbsd/audit3/sys/kern/vfs_syscalls.c#32 integrate .. //depot/projects/trustedbsd/audit3/sys/nfsserver/nfs_serv.c#8 integrate .. //depot/projects/trustedbsd/audit3/sys/nfsserver/nfs_srvsubs.c#7 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit.c#30 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_bsm_klib.c#11 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_ioctl.h#13 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#25 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_private.h#29 integrate .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_worker.c#13 integrate Differences ... ==== //depot/projects/trustedbsd/audit3/lib/libbsm/Makefile#18 (text+ko) ==== @@ -1,5 +1,5 @@ # -# $FreeBSD$ +# $FreeBSD: src/lib/libbsm/Makefile,v 1.2 2006/06/05 12:53:44 rwatson Exp $ # OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm ==== //depot/projects/trustedbsd/audit3/sys/dev/usb/ugen.c#6 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.59 2002/07/11 21:14:28 augustss Exp $ */ +/* $NetBSD: ugen.c,v 1.79 2006/03/01 12:38:13 yamt Exp $ */ /* Also already merged from NetBSD: * $NetBSD: ugen.c,v 1.61 2002/09/23 05:51:20 simonb Exp $ @@ -8,7 +8,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/usb/ugen.c,v 1.105 2006/06/03 10:37:42 iedowse Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/ugen.c,v 1.106 2006/06/05 14:44:39 iedowse Exp $"); /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -284,6 +284,9 @@ ugen_make_devnodes(sc); #endif + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, + USBDEV(sc->sc_dev)); + USB_ATTACH_SUCCESS_RETURN; } @@ -322,9 +325,11 @@ Static void ugen_destroy_devnodes(struct ugen_softc *sc) { - int endptno; + int endptno, prev_sc_dying; struct cdev *dev; + prev_sc_dying = sc->sc_dying; + sc->sc_dying = 1; /* destroy all devices for the other (existing) endpoints as well */ for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) { if (sc->sc_endpoints[endptno][IN].sc != NULL || @@ -341,9 +346,17 @@ dev = sc->sc_endpoints[endptno][IN].dev; else dev = sc->sc_endpoints[endptno][OUT].dev; - destroy_dev(dev); + + KASSERT(dev != NULL, + ("ugen_destroy_devnodes: NULL dev")); + if(dev != NULL) + destroy_dev(dev); + + sc->sc_endpoints[endptno][IN].sc = NULL; + sc->sc_endpoints[endptno][OUT].sc = NULL; } } + sc->sc_dying = prev_sc_dying; } #endif @@ -378,9 +391,10 @@ return (err); /* store an array of endpoint descriptors to clear if the configuration * change succeeds - these aren't available afterwards */ - nendpt_cache = malloc(sizeof(u_int8_t) * niface, M_TEMP, M_WAITOK); + nendpt_cache = malloc(sizeof(u_int8_t) * niface, M_TEMP, M_WAITOK | + M_ZERO); sce_cache_arr = malloc(sizeof(struct ugen_endpoint **) * niface, M_TEMP, - M_WAITOK); + M_WAITOK | M_ZERO); niface_cache = niface; for (ifaceno = 0; ifaceno < niface; ifaceno++) { @@ -727,13 +741,12 @@ sce->state |= UGEN_ASLP; DPRINTFN(5, ("ugenread: sleep on %p\n", sce)); error = tsleep(sce, PZERO | PCATCH, "ugenri", 0); + sce->state &= ~UGEN_ASLP; DPRINTFN(5, ("ugenread: woke, error=%d\n", error)); if (sc->sc_dying) error = EIO; - if (error) { - sce->state &= ~UGEN_ASLP; + if (error) break; - } } splx(s); @@ -793,13 +806,12 @@ sce->state |= UGEN_ASLP; DPRINTFN(5, ("ugenread: sleep on %p\n", sce)); error = tsleep(sce, PZERO | PCATCH, "ugenri", 0); + sce->state &= ~UGEN_ASLP; DPRINTFN(5, ("ugenread: woke, error=%d\n", error)); if (sc->sc_dying) error = EIO; - if (error) { - sce->state &= ~UGEN_ASLP; + if (error) break; - } } while (sce->cur != sce->fill && uio->uio_resid > 0 && !error) { @@ -837,6 +849,9 @@ USB_GET_SC(ugen, UGENUNIT(dev), sc); + if (sc->sc_dying) + return (EIO); + UGEN_DEV_REF(dev, sc); error = ugen_do_read(sc, endpt, uio, flag); UGEN_DEV_RELE(dev, sc); @@ -938,6 +953,9 @@ USB_GET_SC(ugen, UGENUNIT(dev), sc); + if (sc->sc_dying) + return (EIO); + UGEN_DEV_REF(dev, sc); error = ugen_do_write(sc, endpt, uio, flag); UGEN_DEV_RELE(dev, sc); @@ -976,6 +994,20 @@ sce = &sc->sc_endpoints[endpt][IN]; if (sce->pipeh) usbd_abort_pipe(sce->pipeh); + if (sce->state & UGEN_ASLP) { + DPRINTFN(5, ("ugenpurge: waking %p\n", sce)); + wakeup(sce); + } + selwakeuppri(&sce->rsel, PZERO); + + sce = &sc->sc_endpoints[endpt][OUT]; + if (sce->pipeh) + usbd_abort_pipe(sce->pipeh); + if (sce->state & UGEN_ASLP) { + DPRINTFN(5, ("ugenpurge: waking %p\n", sce)); + wakeup(sce); + } + selwakeuppri(&sce->rsel, PZERO); } #endif @@ -1001,6 +1033,7 @@ sce = &sc->sc_endpoints[i][dir]; if (sce->pipeh) usbd_abort_pipe(sce->pipeh); + selwakeuppri(&sce->rsel, PZERO); } } @@ -1040,6 +1073,9 @@ destroy_dev(sc->dev); #endif + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + USBDEV(sc->sc_dev)); + return (0); } @@ -1548,6 +1584,9 @@ USB_GET_SC(ugen, UGENUNIT(dev), sc); + if (sc->sc_dying) + return (EIO); + UGEN_DEV_REF(dev, sc); error = ugen_do_ioctl(sc, endpt, cmd, addr, flag, p); UGEN_DEV_RELE(dev, sc); @@ -1558,43 +1597,57 @@ ugenpoll(struct cdev *dev, int events, usb_proc_ptr p) { struct ugen_softc *sc; - struct ugen_endpoint *sce; + struct ugen_endpoint *sce_in, *sce_out; + usb_endpoint_descriptor_t *edesc; int revents = 0; int s; USB_GET_SC(ugen, UGENUNIT(dev), sc); if (sc->sc_dying) - return (EIO); + return ((events & (POLLIN | POLLOUT | POLLRDNORM | + POLLWRNORM)) | POLLHUP); + /* Do not allow to poll a control endpoint */ + if (UGENENDPOINT(dev) == USB_CONTROL_ENDPOINT) + return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); + + sce_in = &sc->sc_endpoints[UGENENDPOINT(dev)][IN]; + sce_out = &sc->sc_endpoints[UGENENDPOINT(dev)][OUT]; + edesc = (sce_in->edesc != NULL) ? sce_in->edesc : sce_out->edesc; + KASSERT(edesc != NULL, ("ugenpoll: NULL edesc")); + if (sce_in->edesc == NULL || sce_in->pipeh == NULL) + sce_in = NULL; + if (sce_out->edesc == NULL || sce_out->pipeh == NULL) + sce_out = NULL; - /* XXX always IN */ - sce = &sc->sc_endpoints[UGENENDPOINT(dev)][IN]; -#ifdef DIAGNOSTIC - if (!sce->edesc) { - printf("ugenpoll: no edesc\n"); - return (EIO); - } - if (!sce->pipeh) { - printf("ugenpoll: no pipe\n"); - return (EIO); - } -#endif s = splusb(); - switch (sce->edesc->bmAttributes & UE_XFERTYPE) { + switch (edesc->bmAttributes & UE_XFERTYPE) { case UE_INTERRUPT: - if (events & (POLLIN | POLLRDNORM)) { - if (sce->q.c_cc > 0) + if (sce_in != NULL && (events & (POLLIN | POLLRDNORM))) { + if (sce_in->q.c_cc > 0) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sce->rsel); + selrecord(p, &sce_in->rsel); + } + if (sce_out != NULL && (events & (POLLOUT | POLLWRNORM))) { + if (sce_out->q.c_cc > 0) + revents |= events & (POLLOUT | POLLWRNORM); + else + selrecord(p, &sce_out->rsel); } break; case UE_ISOCHRONOUS: - if (events & (POLLIN | POLLRDNORM)) { - if (sce->cur != sce->fill) + if (sce_in != NULL && (events & (POLLIN | POLLRDNORM))) { + if (sce_in->cur != sce_in->fill) revents |= events & (POLLIN | POLLRDNORM); else - selrecord(p, &sce->rsel); + selrecord(p, &sce_in->rsel); + } + if (sce_out != NULL && (events & (POLLOUT | POLLWRNORM))) { + if (sce_out->cur != sce_out->fill) + revents |= events & (POLLOUT | POLLWRNORM); + else + selrecord(p, &sce_out->rsel); } break; case UE_BULK: ==== //depot/projects/trustedbsd/audit3/sys/kern/vfs_syscalls.c#32 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.414 2006/03/31 03:54:19 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_syscalls.c,v 1.415 2006/06/05 13:34:23 rwatson Exp $"); #include "opt_compat.h" #include "opt_mac.h" ==== //depot/projects/trustedbsd/audit3/sys/nfsserver/nfs_serv.c#8 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/nfsserver/nfs_serv.c,v 1.164 2006/03/31 03:54:19 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/nfsserver/nfs_serv.c,v 1.165 2006/06/05 14:48:02 kib Exp $"); /* * nfs version 2 and 3 server calls to vnode ops @@ -570,6 +570,10 @@ error = lookup(&ind); ind.ni_dvp = NULL; + if (ind.ni_cnd.cn_flags & GIANTHELD) { + mtx_unlock(&Giant); + ind.ni_cnd.cn_flags &= ~GIANTHELD; + } if (error == 0) { /* @@ -1918,6 +1922,10 @@ error = lookup(&nd); nd.ni_dvp = NULL; + if (nd.ni_cnd.cn_flags & GIANTHELD) { + mtx_unlock(&Giant); + nd.ni_cnd.cn_flags &= ~GIANTHELD; + } if (error) goto ereply; @@ -2145,6 +2153,10 @@ error = lookup(&nd); nd.ni_dvp = NULL; + if (nd.ni_cnd.cn_flags & GIANTHELD) { + mtx_unlock(&Giant); + nd.ni_cnd.cn_flags &= ~GIANTHELD; + } if (error) goto out; @@ -2886,6 +2898,10 @@ error = lookup(&nd); nd.ni_dvp = NULL; + if (nd.ni_cnd.cn_flags & GIANTHELD) { + mtx_unlock(&Giant); + nd.ni_cnd.cn_flags &= ~GIANTHELD; + } if (error == 0) { bzero((caddr_t)fhp, sizeof(nfh)); ==== //depot/projects/trustedbsd/audit3/sys/nfsserver/nfs_srvsubs.c#7 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/nfsserver/nfs_srvsubs.c,v 1.140 2006/04/02 04:24:57 cel Exp $"); +__FBSDID("$FreeBSD: src/sys/nfsserver/nfs_srvsubs.c,v 1.141 2006/06/05 14:48:02 kib Exp $"); /* * These functions support the macros and help fiddle mbuf chains for @@ -876,6 +876,10 @@ } if (!lockleaf) cnp->cn_flags &= ~LOCKLEAF; + if (cnp->cn_flags & GIANTHELD) { + mtx_unlock(&Giant); + cnp->cn_flags &= ~GIANTHELD; + } /* * nfs_namei() guarentees that fields will not contain garbage ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit.c#30 (text+ko) ==== @@ -27,7 +27,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/security/audit/audit.c,v 1.12 2006/03/19 17:34:00 rwatson Exp $ + * $FreeBSD: src/sys/security/audit/audit.c,v 1.15 2006/06/05 14:48:17 rwatson Exp $ */ #include ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_bsm_klib.c#11 (text+ko) ==== @@ -27,7 +27,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/security/audit/audit_bsm_klib.c,v 1.3 2006/06/01 15:38:30 csjp Exp $ + * $FreeBSD: src/sys/security/audit/audit_bsm_klib.c,v 1.4 2006/06/05 14:48:17 rwatson Exp $ */ #include ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_ioctl.h#13 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: src/sys/security/audit/audit_ioctl.h,v 1.3 2006/06/05 14:48:17 rwatson Exp $ */ #ifndef _SECURITY_AUDIT_AUDIT_IOCTL_H_ ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#25 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/security/audit/audit_pipe.c,v 1.6 2006/03/19 15:39:03 rwatson Exp $ + * $FreeBSD: src/sys/security/audit/audit_pipe.c,v 1.7 2006/06/05 14:48:17 rwatson Exp $ */ #include ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_private.h#29 (text+ko) ==== @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/security/audit/audit_private.h,v 1.7 2006/03/19 17:34:00 rwatson Exp $ + * $FreeBSD: src/sys/security/audit/audit_private.h,v 1.9 2006/06/05 14:48:17 rwatson Exp $ */ /* ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_worker.c#13 (text+ko) ==== @@ -27,7 +27,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: src/sys/security/audit/audit_worker.c,v 1.8 2006/06/05 14:48:17 rwatson Exp $ */ #include