From 59cfd37dd43b187dbb1f3740fac46bd7434bc9f4 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 11 Apr 2002 21:17:45 +0000 Subject: [PATCH] Use the proc lock to protect p_ucred while we read a few items from it. --- sys/security/lomac/kernel_log.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/security/lomac/kernel_log.c b/sys/security/lomac/kernel_log.c index 5e9bf154435..56665f5cd3c 100644 --- a/sys/security/lomac/kernel_log.c +++ b/sys/security/lomac/kernel_log.c @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include #include @@ -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) { + uid_t uid; + pid_t pgid; - (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, + 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() */