PERFORCE change 85610 for review
Robert Watson
rwatson at FreeBSD.org
Thu Oct 20 18:44:37 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=85610
Change 85610 by rwatson at rwatson_zoo on 2005/10/20 18:44:37
Simplify token allocation code: because we allocate with M_WAITOK,
failure isn't permitted.
When we abandon an audit record because we don't know how to
convert it to BSM, make sure that we free the BSM subject token
allocated before this decision was made.
Affected files ...
.. //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_audit.c#27 edit
.. //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_token.c#12 edit
Differences ...
==== //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_audit.c#27 (text+ko) ====
@@ -116,16 +116,11 @@
tm.tv_usec = ctime->tv_nsec / 1000;
tm.tv_sec = ctime->tv_sec;
hdr = au_to_header32(tot_rec_size, event, 0, tm);
-
- if (hdr != NULL) {
- /* Add to head of list */
- TAILQ_INSERT_HEAD(&rec->token_q, hdr, tokens);
+ TAILQ_INSERT_HEAD(&rec->token_q, hdr, tokens);
+
+ trail = au_to_trailer(tot_rec_size);
+ TAILQ_INSERT_TAIL(&rec->token_q, trail, tokens);
- trail = au_to_trailer(tot_rec_size);
- if (trail != NULL)
- TAILQ_INSERT_TAIL(&rec->token_q, trail,
- tokens);
- }
/* Serialize token data to the record. */
rec->len = tot_rec_size;
@@ -1052,6 +1047,8 @@
default: /* We shouldn't fall through to here. */
printf("BSM conversion requested for unknown event %d\n",
ar->ar_event);
+ /* Write the subject token so it is properly freed here. */
+ kau_write(rec, subj_tok);
kau_free(rec);
return (BSM_NOAUDIT);
}
==== //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_token.c#12 (text+ko) ====
@@ -59,16 +59,9 @@
#define GET_TOKEN_AREA(t, dptr, length) do { \
t = malloc(sizeof(token_t), M_AUDITBSM, M_WAITOK); \
- if (t != NULL) { \
- t->len = length; \
- t->t_data = malloc(length * sizeof(u_char), \
- M_AUDITBSM, M_WAITOK); \
- if ((dptr = t->t_data) == NULL) { \
- free(t, M_AUDITBSM); \
- t = NULL; \
- } else \
- memset(dptr, 0, length); \
- } \
+ t->t_data = malloc(length, M_AUDITBSM, M_WAITOK | M_ZERO); \
+ t->len = length; \
+ dptr = t->t_data; \
} while (0)
/*
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list