PERFORCE change 167342 for review
Ilias Marinos
marinosi at FreeBSD.org
Fri Aug 14 21:45:21 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167342
Change 167342 by marinosi at marinosi_redrum on 2009/08/14 21:44:39
Debugging code.(Note audit_enabled on for all slices!)
Affected files ...
.. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit.c#23 edit
.. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.c#10 edit
.. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.h#16 edit
.. //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_worker.c#9 edit
Differences ...
==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit.c#23 (text) ====
@@ -759,7 +759,7 @@
* XXX: As M_ZERO flag is used during allocation, some of the
* following initilization is pointless and should be removed.
*/
- as->audit_enabled = 0;
+ as->audit_enabled = 1;
as->audit_suspended = 0;
as->audit_panic_on_write_fail = 0;
as->audit_fail_stop = 0;
@@ -861,12 +861,12 @@
* code.
*/
int
-audit_slice_commit_rec(void *rec, struct audit_slice *as)
+audit_slice_commit_rec(struct thread *td, void *rec, struct audit_slice *as)
{
struct kaudit_record *ar = NULL;
int error;
- struct thread *td = NULL;
+ uprintf("IN audit_slice_commit_rec()\n");
/*
* XXXRW: This error value seems never to be used? Possibly we
* should validate the record before calling audit_new, and return
@@ -879,6 +879,7 @@
*/
/* Verify the record. */
if (bsm_rec_verify(rec) == 0) {
+ uprintf("Error in record!\n");
error = EINVAL;
return (error);
}
@@ -906,9 +907,11 @@
* base slice may already be using it to record the write
* syscall.
*/
+ uprintf("Calling audit_new().\n");
ar = audit_new(AUE_NULL, td, as);
if (ar == NULL)
return (1);
+ uprintf("audit_new() returned a non-NULL ar.\n");
/*
* Note: it could be that some records initiated while audit was
@@ -937,6 +940,7 @@
as->audit_pre_q_len--;
cv_signal(&(as->audit_worker_cv));
mtx_unlock(&(as->audit_mtx));
+ uprintf("audit_slice_commit_rec(): Reached the end!\n");
return (0);
}
==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.c#10 (text+ko) ====
@@ -169,31 +169,31 @@
int c, error = 0;
//u_int32_t recsz = 0;
//int nbytes = 0; /*Remaining bytes */
- char *audit_slice_dev_buf;
+ void *audit_slice_dev_buf = NULL;
struct audit_slice *as;
- void *as_rec = NULL;
+ //void *as_rec = NULL;
as = dev->si_drv1;
/* Safe malloc the pagesz of the system.*/
//audit_slice_dev_buf = malloc(sizeof(*audit_slice_dev_buf),
// M_TEMP, M_WAITOK);
- audit_slice_dev_buf = (void *)malloc(PAGE_SIZE, M_TEMP,
- M_WAITOK | M_ZERO);
-
- uprintf("[DEV_WRITE_METHOD] of slice %s.\n", as->as_name);
-
- /* Copy the string in from user memory to kernel memory */
- c = MIN(uio->uio_iov->iov_len,PAGE_SIZE);
- error = copyin(uio->uio_iov->iov_base, audit_slice_dev_buf, c);
-
- /* Null terminate it */
- *(audit_slice_dev_buf + c) = 0;
-
- if (error != 0)
- uprintf("Write failed: bad address!\n");
- else
- uprintf ("MESSAGE: %s\n", (char *) audit_slice_dev_buf);
+// audit_slice_dev_buf = (void *)malloc(PAGE_SIZE, M_TEMP,
+// M_WAITOK | M_ZERO);
+//
+// uprintf("[DEV_WRITE_METHOD] of slice %s.\n", as->as_name);
+//
+// /* Copy the string in from user memory to kernel memory */
+// c = MIN(uio->uio_iov->iov_len,PAGE_SIZE);
+// error = copyin(uio->uio_iov->iov_base, audit_slice_dev_buf, c);
+//
+// /* Null terminate it */
+// *(audit_slice_dev_buf + c) = 0;
+//
+// if (error != 0)
+// uprintf("Write failed: bad address!\n");
+// else
+// uprintf ("MESSAGE: %s\n", (char *) audit_slice_dev_buf);
/*
* XXXRW: This seems to handle multiple records/system call, but not
* multiple system calls/record. To handle the latter, we need to
@@ -201,15 +201,19 @@
* into until we have a complete record which we can then submit to
* audit.
*/
-// while (uio->uio_resid > 0) {
-// c = MIN((int)uio->uio_resid, sizeof(*audit_slice_dev_buf));
-// if ( c == (int)uio->uio_resid )
-// break;
-//
-// /* Fetch the bsm record's header */
-// error = uiomove(audit_slice_dev_buf, c, uio);
-// if (error)
-// break;
+ while (uio->uio_resid > 0) {
+ //c = MIN((int)uio->uio_resid, sizeof(*audit_slice_dev_buf));
+ //if ( c == (int)uio->uio_resid )
+ // break;
+
+ c = (int)uio->uio_resid;
+ audit_slice_dev_buf = malloc(c, M_TEMP, M_WAITOK | M_ZERO);
+
+
+ /* Fetch the bsm record's header */
+ error = uiomove(audit_slice_dev_buf, c, uio);
+ if (error)
+ break;
//
// /*
// * Store the actual record's size. Add some checks before
@@ -232,7 +236,7 @@
// if (error)
// break;
- //audit_slice_commit_rec( as_rec, as);
+ audit_slice_commit_rec( uio->uio_td, audit_slice_dev_buf, as);
// uprintf("Size to be fetched: %d\n", uio->uio_resid);
// c = MIN((int)uio->uio_resid, PAGE_SIZE);
@@ -245,14 +249,14 @@
-// }
+ }
/*
* XXXRW: Only free as_rec if we allocated it.
*/
free(audit_slice_dev_buf, M_TEMP);
- if (as_rec != NULL)
- free(as_rec, M_AUDITBSM);
+// if (as_rec != NULL)
+// free(as_rec, M_AUDITBSM);
return (error);
}
==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_slice.h#16 (text+ko) ====
@@ -186,15 +186,17 @@
/*
* Audit related functions prototypes.
*/
-void audit_rotate_vnode(struct audit_slice *as, struct ucred *cred, struct vnode *vp);
+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);
void audit_slice_cdev_init(struct audit_slice *as);
-int audit_slice_commit_rec(void *rec, struct audit_slice *as);
+int audit_slice_commit_rec(struct thread *td, void *rec,
+ struct audit_slice *as);
struct audit_slice *audit_slice_lookup(char *as_name);
-int auditon_slice_internal(struct thread *td, int cmd, char *as_name, void *data,
- u_int length);
+int auditon_slice_internal(struct thread *td, int cmd, char *as_name,
+ void *data, u_int length);
#endif /* ! _SECURITY_AUDIT_SLICE_H_ */
==== //depot/projects/soc2009/marinosi_appaudit/src/sys/security/audit/audit_worker.c#9 (text) ====
@@ -223,6 +223,7 @@
}
}
+ uprintf("Ready to write record!\n");
error = vn_rdwr(UIO_WRITE, as->audit_vp, data, len, (off_t)0, UIO_SYSSPACE,
IO_APPEND|IO_UNIT, as->audit_cred, NULL, NULL, curthread);
if (error == ENOSPC)
@@ -406,6 +407,7 @@
while (TAILQ_EMPTY(&(as->audit_q)))
cv_wait(&(as->audit_worker_cv), &(as->audit_mtx));
+ uprintf("audit_worker(): Record in the queue!\n");
/*
* If there are records in the global audit record queue,
* transfer them to a thread-local queue and process them
@@ -427,6 +429,7 @@
mtx_unlock(&(as->audit_mtx));
while ((ar = TAILQ_FIRST(&ar_worklist))) {
TAILQ_REMOVE(&ar_worklist, ar, k_q);
+ uprintf("audit_worker(): Calling audit_worker_process_record()!\n");
audit_worker_process_record(ar, as);
audit_free(ar);
}
More information about the p4-projects
mailing list