From owner-p4-projects Tue Apr 9 13:22:52 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B0FCB37B41D; Tue, 9 Apr 2002 13:22:16 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id CE4F937B494; Tue, 9 Apr 2002 13:21:10 -0700 (PDT) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.6/8.11.6) with SMTP id g39KL3d09951; Tue, 9 Apr 2002 16:21:03 -0400 (EDT) (envelope-from arr@FreeBSD.org) X-Authentication-Warning: fledge.watson.org: arr owned process doing -bs Date: Tue, 9 Apr 2002 16:21:02 -0400 (EDT) From: "Andrew R. Reiter" X-Sender: arr@fledge.watson.org To: John Baldwin Cc: "Andrew R. Reiter" , Perforce Change Reviews Subject: RE: PERFORCE change 9457 for review In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 9 Apr 2002, John Baldwin wrote: : :On 09-Apr-2002 Andrew R. Reiter wrote: :> http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9457 :> :> Change 9457 by arr@arr_shibby on 2002/04/09 12:20:46 :> :> - Use curthread instead of a passed in thread pointer in :> some places. :> - Remember crfree() our saved cred. : :You don't do a crhold on it though, which you probably should. Erps -- this is probably something I accidentally chopped. Most of this code is some stuff I'm cleaning out while I ponder a design change. Thanks for the feedback. Cheers, Andrew : :> - Rearrange a check of the shutdown flag, so we can better :> handle a bad situation -- this needs to possibly lock :> the flag on write :> :> Affected files ... :> :> ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#20 edit :> :> Differences ... :> :> ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#20 (text+ko) :> ==== :> :> @@ -87,9 +87,6 @@ :> audit_record_generate_id(audit_id_t *id) :> { :> :> - /* :> - * XXX :> - */ :> return(*++id); :> } :> :> @@ -128,7 +125,6 @@ :> { :> struct vnode *vp; :> struct audit_info *ai; :> - struct ucred *cred; :> vm_zone_t zone; :> char *sptr; :> int err = 0; :> @@ -141,8 +137,7 @@ :> sptr = malloc(strlen(AUDLOG), M_TEMP, M_WAITOK|M_ZERO); :> strcpy(sptr, AUDLOG); :> :> - /* XXX curthread */ :> - vp = audit_write_init(sptr, curthread, &cred); :> + vp = audit_write_init(sptr, curthread, curthread->td_ucred); :> if (vp == NULL) :> panic("Unable to init audit system.\n"); :> :> @@ -151,7 +146,7 @@ :> panic("audit_init: unable to init audit record zone"); :> :> AINFO_LOCK(ai); :> - ai->ai_cred = cred; :> + ai->ai_cred = curthread->td_ucred; : :Here, do a crhold() so you preserve your own reference in case this audit info :lives longer than the syscall. : :> ai->ai_vp = vp; :> ai->ai_zone = zone; :> ai->ai_lname = sptr; :> @@ -169,15 +164,17 @@ :> SYSINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_init, NULL); :> :> void :> -audit_shutdown(int what, void *arg, struct thread *td) :> +audit_shutdown(void) :> { :> struct vnode *vp; :> - struct audit_info *ai = arg; :> + struct audit_info *ai; :> struct ucred *cred; :> vm_zone_t zone = NULL; :> char *ptr; :> :> audit_shutdown_flag = 1; :> + ai = &ainfo; :> + :> AINFO_LOCK(ai); :> cred = ai->ai_cred; :> vp = ai->ai_vp; :> @@ -185,10 +182,10 @@ :> ptr = ai->ai_lname; :> AINFO_UNLOCK(ai); :> mtx_destroy(&ai->ai_mtx); :> + free(ptr, M_TEMP); :> bzero(ai, sizeof(*ai)); :> - :> - free(ptr, M_TEMP); :> - audit_write_shutdown(vp, td, cred); :> + audit_write_shutdown(vp, curthread, cred); /* curthread ok? */ :> + crfree(cred); :> zdestroy(zone); :> } :> SYSUNINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_shutdown, NULL); :> @@ -300,19 +297,20 @@ :> mtx_lock(&record_queue_mtx); :> TAILQ_REMOVE(&record_queue, ar, ar_next); :> mtx_unlock(&record_queue_mtx); :> + :> + /* XXX Check flag here and hope it doesnt change. */ :> + if (audit_shutdown_flag) { :> + mtx_destroy(&record_queue_mtx); :> + kthread_exit(0); :> + } :> + :> if (ar) { :> - /* XXX */ :> (void)audit_record_write(ar, NULL, NULL); :> AINFO_LOCK(ai); :> z = ai->ai_zone; :> lease = &ai->ai_leased; :> AINFO_UNLOCK(ai); :> audit_record_free(ar, z, lease); :> - } else if (ar == NULL && audit_shutdown_flag) { :> - mtx_destroy(&record_queue_mtx); :> - kthread_exit(0); :> } :> - if (audit_shutdown_flag) :> - continue; :> } :> } : :-- : :John Baldwin <>< http://www.FreeBSD.org/~jhb/ :"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ : -- Andrew R. Reiter arr@watson.org arr@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message