Date: Sun, 9 Aug 2009 09:02:33 GMT From: Ilias Marinos <marinosi@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 167125 for review Message-ID: <200908090902.n7992XoC079947@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167125 Change 167125 by marinosi@marinosi_redrum on 2009/08/09 09:02:20 Several fixes , minor corrections following rwatson's directions. Affected files ... .. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit.c#14 edit .. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.h#12 edit .. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_syscalls.c#8 edit .. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_worker.c#6 edit Differences ... ==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit.c#14 (text) ==== @@ -284,7 +284,7 @@ SHUTDOWN_PRI_FIRST); /* Start audit worker thread. */ - audit_worker_init(as); + audit_worker_start(as); } /* Init the base slice */ @@ -299,12 +299,16 @@ * drain before returning, which could lead to lost records on shutdown. * * XXXRW: Presumably we need this to iterate over all slices? + * FIXED. */ void audit_shutdown(void *arg, int howto) { - audit_rotate_vnode(NULL, NULL); + /* + * Base slice is a temporary arg. + */ + audit_rotate_vnode(audit_base_slice, NULL, NULL); } /* @@ -720,7 +724,7 @@ */ /* Start audit worker thread. */ - audit_worker_init(as); + audit_worker_start(as); /* Create the special device node */ audit_slice_cdev_init(as); ==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.h#12 (text+ko) ==== @@ -187,8 +187,8 @@ /* * Audit related functions prototypes. */ -void audit_rotate_vnode(struct ucred *cred, struct vnode *vp); -void audit_worker_init(void *arg); +void audit_rotate_vnode(struct audit_slice *as, struct ucred *cred, struct vnode *vp); +void audit_worker_start(struct audit_slice *as); void audit_slice_init(struct audit_slice *as, char *name); void audit_slice_create(char *name); int audit_slice_destroy(struct audit_slice *as); ==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_syscalls.c#8 (text) ==== @@ -860,7 +860,7 @@ audit_base_slice->audit_suspended = 0; audit_suspended = audit_base_slice->audit_suspended; - audit_rotate_vnode(cred, vp); + audit_rotate_vnode(audit_base_slice, cred, vp); return (error); } ==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_worker.c#6 (text) ==== @@ -80,12 +80,12 @@ * XXXRW: 'as' should be passed in as an explicit macro argument to avoid * side effect semantics. */ -#define AUDIT_WORKER_LOCK_INIT() sx_init(&(as->audit_worker_lock), \ +#define AUDIT_WORKER_LOCK_INIT(x) sx_init(&(x->audit_worker_lock), \ "audit_worker_lock"); -#define AUDIT_WORKER_LOCK_ASSERT() sx_assert(&(as->audit_worker_lock), \ +#define AUDIT_WORKER_LOCK_ASSERT(x) sx_assert(&(x->audit_worker_lock), \ SA_XLOCKED) -#define AUDIT_WORKER_LOCK() sx_xlock(&(as->audit_worker_lock)) -#define AUDIT_WORKER_UNLOCK() sx_xunlock(&(as->audit_worker_lock)) +#define AUDIT_WORKER_LOCK(x) sx_xlock(&(x->audit_worker_lock)) +#define AUDIT_WORKER_UNLOCK(x) sx_xunlock(&(x->audit_worker_lock)) /* * Write an audit record to a file, performed as the last stage after both @@ -108,7 +108,7 @@ struct vattr vattr; long temp; - AUDIT_WORKER_LOCK_ASSERT(); + AUDIT_WORKER_LOCK_ASSERT(as); if (as->audit_vp == NULL) return; @@ -188,7 +188,7 @@ */ if ((as->audit_fstat.af_filesz != 0) && (as->audit_file_rotate_wait == 0) && (vattr.va_size >= as->audit_fstat.af_filesz)) { - AUDIT_WORKER_LOCK_ASSERT(); + AUDIT_WORKER_LOCK_ASSERT(as); as->audit_file_rotate_wait = 1; (void)audit_send_trigger(AUDIT_TRIGGER_ROTATE_KERNEL); @@ -308,7 +308,7 @@ if (((ar->k_ar_commit & AR_COMMIT_USER) && (ar->k_ar_commit & AR_PRESELECT_USER_TRAIL)) || (ar->k_ar_commit & AR_PRESELECT_TRAIL)) { - AUDIT_WORKER_LOCK(); + AUDIT_WORKER_LOCK(as); locked = 1; } else locked = 0; @@ -319,7 +319,7 @@ */ if ((ar->k_ar_commit & AR_COMMIT_USER) && (ar->k_ar_commit & AR_PRESELECT_USER_TRAIL)) { - AUDIT_WORKER_LOCK_ASSERT(); + AUDIT_WORKER_LOCK_ASSERT(as); audit_record_write(as, ar->k_udata, ar->k_ulen); } @@ -358,7 +358,7 @@ } if (ar->k_ar_commit & AR_PRESELECT_TRAIL) { - AUDIT_WORKER_LOCK_ASSERT(); + AUDIT_WORKER_LOCK_ASSERT(as); audit_record_write(as, bsm->data, bsm->len); } @@ -370,7 +370,7 @@ kau_free(bsm); out: if (locked) - AUDIT_WORKER_UNLOCK(); + AUDIT_WORKER_UNLOCK(as); } /* @@ -447,14 +447,12 @@ * audit_base_slice in the future, as well. */ void -audit_rotate_vnode(struct ucred *cred, struct vnode *vp) +audit_rotate_vnode(struct audit_slice *as, struct ucred *cred, struct vnode *vp) { struct ucred *old_audit_cred; struct vnode *old_audit_vp; - struct audit_slice *as; int vfslocked; - as = audit_base_slice; KASSERT((cred != NULL && vp != NULL) || (cred == NULL && vp == NULL), ("audit_rotate_vnode: cred %p vp %p", cred, vp)); @@ -463,7 +461,7 @@ * Rotate the vnode/cred, and clear the rotate flag so that we will * send a rotate trigger if the new file fills. */ - AUDIT_WORKER_LOCK(); + AUDIT_WORKER_LOCK(as); old_audit_cred = as->audit_cred; old_audit_vp = as->audit_vp; as->audit_cred = cred; @@ -471,7 +469,7 @@ as->audit_file_rotate_wait = 0; as->audit_enabled = (as->audit_vp != NULL); audit_enabled = as->audit_enabled; - AUDIT_WORKER_UNLOCK(); + AUDIT_WORKER_UNLOCK(as); /* * If there was an old vnode/credential, close and free. @@ -488,16 +486,16 @@ /* * XXXRW: Can replace void *arg with a simple audit_slice pointer now. * Perhaps rename to audit_worker_start() and need an audit_worker_stop(). + * FIXED. */ void -audit_worker_init(void *arg) +audit_worker_start(struct audit_slice *as) { int error; - struct audit_slice *as = (struct audit_slice * ) arg; - AUDIT_WORKER_LOCK_INIT(); + AUDIT_WORKER_LOCK_INIT(as); error = kproc_create(audit_worker,(void *) as, &(as->audit_thread), RFHIGHPID, 0, as->as_name); if (error) - panic("audit_worker_init: kproc_create returned %d", error); + panic("audit_worker_start: kproc_create returned %d", error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908090902.n7992XoC079947>