summaryrefslogtreecommitdiffstats
path: root/sys/security/lomac
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-04-11 21:17:45 +0000
committerjhb <jhb@FreeBSD.org>2002-04-11 21:17:45 +0000
commit7b11cd5cb00ed4581da6603acdbf71b04609869e (patch)
tree526cb0f2c9283cb404693cfd49e31a7c710996cb /sys/security/lomac
parente3b656d4d9f6edec92c8dd1c1975b24db580b985 (diff)
downloadFreeBSD-src-7b11cd5cb00ed4581da6603acdbf71b04609869e.zip
FreeBSD-src-7b11cd5cb00ed4581da6603acdbf71b04609869e.tar.gz
Use the proc lock to protect p_ucred while we read a few items from it.
Diffstat (limited to 'sys/security/lomac')
-rw-r--r--sys/security/lomac/kernel_log.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/security/lomac/kernel_log.c b/sys/security/lomac/kernel_log.c
index 5e9bf15..56665f5 100644
--- a/sys/security/lomac/kernel_log.c
+++ b/sys/security/lomac/kernel_log.c
@@ -37,6 +37,8 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
@@ -129,9 +131,14 @@ log_append_int(lomac_log_t *s, int data) {
void
log_append_subject_id(lomac_log_t *s, const lomac_subject_t *p_subject) {
-
- (void)sbuf_printf(s, "p%dg%du%d:%s", p_subject->p_pid,
- p_subject->p_pgrp->pg_id, p_subject->p_ucred->cr_uid,
+ uid_t uid;
+ pid_t pgid;
+
+ PROC_LOCK(p_subject);
+ uid = p_subject->p_ucred->cr_uid;
+ pgid = p_subject->p_pgrp->pg_id;
+ PROC_UNLOCK(p_subject);
+ (void)sbuf_printf(s, "p%dg%du%d:%s", p_subject->p_pid, pgid, uid,
p_subject->p_comm);
} /* log_append_subject_id() */
OpenPOWER on IntegriCloud