From owner-p4-projects@FreeBSD.ORG Sun Aug 6 10:18:34 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 83FAB16A4E1; Sun, 6 Aug 2006 10:18:34 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5ECE516A4DE for ; Sun, 6 Aug 2006 10:18:34 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 060DA43D53 for ; Sun, 6 Aug 2006 10:18:34 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k76AIXXP037508 for ; Sun, 6 Aug 2006 10:18:33 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k76AIVDj037505 for perforce@freebsd.org; Sun, 6 Aug 2006 10:18:31 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 6 Aug 2006 10:18:31 GMT Message-Id: <200608061018.k76AIVDj037505@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 103317 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2006 10:18:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=103317 Change 103317 by rwatson@rwatson_zoo on 2006/08/06 10:17:32 Initial placement of MAC checks in audit system calls. Affected files ... .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_syscalls.c#19 edit Differences ... ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_syscalls.c#19 (text+ko) ==== @@ -29,7 +29,17 @@ * $FreeBSD: src/sys/security/audit/audit_syscalls.c,v 1.4 2006/06/05 22:36:12 rwatson Exp $ */ +/* + * XXXRW: The MAC checks here vary in location based on when the arguments + * they need have been copied in. Probably, we should universally adopt the + * order: (1) copy in arguments (2) audit arguments (3) MAC check + * (4) suser() check. + */ + +#include "opt_mac.h" + #include +#include #include #include #include @@ -112,6 +122,12 @@ goto free_out; } +#ifdef MAC + error = mac_check_system_audit(td->td_ucred, rec, uap->length); + if (error) + goto free_out; +#endif + /* * Attach the user audit record to the kernel audit record. Because * this system call is an auditable event, we will write the user @@ -148,6 +164,13 @@ struct proc *tp; AUDIT_ARG(cmd, uap->cmd); + +#ifdef MAC + error = mac_check_system_auditon(td->td_ucred, uap->cmd); + if (error) + return (error); +#endif + error = suser(td); if (error) return (error); @@ -394,6 +417,12 @@ int error; au_id_t id; +#ifdef MAC + error = mac_check_proc_getauid(td->td_ucred); + if (error) + return (error); +#endif + error = suser(td); if (error) return (error); @@ -426,6 +455,12 @@ audit_arg_auid(id); +#ifdef MAC + error = mac_check_proc_setauid(td->td_ucred, id); + if (error) + return (error); +#endif + /* * XXX: Integer write on static pointer dereference: doesn't need * locking? @@ -454,6 +489,12 @@ struct auditinfo ai; int error; +#ifdef MAC + error = mac_check_proc_getaudit(td->td_ucred); + if (error) + return (error); +#endif + error = suser(td); if (error) return (error); @@ -483,6 +524,12 @@ audit_arg_auditinfo(&ai); +#ifdef MAC + error = mac_check_proc_setaudit(td->td_ucred, &ai); + if (error) + return (error); +#endif + /* * XXXRW: Test privilege while holding the proc lock? */ @@ -500,6 +547,12 @@ { int error; +#ifdef MAC + error = mac_check_proc_getaudit(td->td_ucred); + if (error) + return (error); +#endif + error = suser(td); if (error) return (error); @@ -516,6 +569,13 @@ error = suser(td); if (error) return (error); + +#ifdef MAC + error = mac_check_proc_setaudit(td->td_ucred, NULL); + if (error) + return (error); +#endif + return (ENOSYS); }