From owner-p4-projects Thu Oct 10 10:58:17 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6AA7E37B404; Thu, 10 Oct 2002 10:58:06 -0700 (PDT) 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 8916A37B4CE for ; Thu, 10 Oct 2002 10:58:05 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2087D43EA9 for ; Thu, 10 Oct 2002 10:58:05 -0700 (PDT) (envelope-from green@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id g9AHvpMt090531 for ; Thu, 10 Oct 2002 10:57:51 -0700 (PDT) (envelope-from green@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.3/Submit) id g9AHvoXG090528 for perforce@freebsd.org; Thu, 10 Oct 2002 10:57:50 -0700 (PDT) Date: Thu, 10 Oct 2002 10:57:50 -0700 (PDT) Message-Id: <200210101757.g9AHvoXG090528@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to green@freebsd.org using -f From: Brian Feldman Subject: PERFORCE change 19038 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=19038 Change 19038 by green@green_laptop_2 on 2002/10/10 10:57:32 Convert the thread_userret mac event hook to be based upon the AST mechanism. This requires specifically tripping the AST (as seen in the mac_test modules) in order for the hook to be called, and so removes the overhead from the common userret case as requested by bde. Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/subr_trap.c#16 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#55 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac.h#177 edit .. //depot/projects/trustedbsd/mac/sys/sys/proc.h#24 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/subr_trap.c#16 (text+ko) ==== @@ -91,10 +91,6 @@ mtx_unlock(&Giant); #endif -#ifdef MAC - mac_thread_userret(td); -#endif - /* * XXX we cheat slightly on the locking here to avoid locking in * the usual case. Setting td_priority here is essentially an @@ -195,6 +191,9 @@ flags = ke->ke_flags; sflag = p->p_sflag; p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND | PS_XCPU); +#ifdef MAC + p->p_sflag &= ~PS_MACPEND; +#endif /* MAC */ ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC); cnt.v_soft++; prticks = 0; @@ -248,6 +247,10 @@ } PROC_UNLOCK(p); } +#ifdef MAC + if (sflag & PS_MACPEND) + mac_thread_userret(td); +#endif /* MAC */ if (flags & KEF_NEEDRESCHED) { mtx_lock_spin(&sched_lock); td->td_priority = kg->kg_user_pri; ==== //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#55 (text+ko) ==== @@ -825,10 +825,27 @@ } +static int +sysctl_mac_test_thread_userret(SYSCTL_HANDLER_ARGS) +{ + + mtx_lock_spin(&sched_lock); + curthread->td_kse->ke_flags |= KEF_ASTPENDING; + curthread->td_proc->p_sflag |= PS_MACPEND; + mtx_unlock_spin(&sched_lock); + return (sysctl_handle_int(oidp, NULL, curthread->td_proc->p_pid, + req)); +} +SYSCTL_PROC(_security_mac_test, OID_AUTO, thread_userret, + CTLTYPE_INT | CTLFLAG_RD, 0, 0, sysctl_mac_test_thread_userret, "I", + "Set the flag for MAC AST pending and return pid"); + static void mac_test_thread_userret(struct thread *td) { + printf("mac_test_thread_userret(process = %d)\n", + curthread->td_proc->p_pid); } /* ==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#177 (text+ko) ==== ==== //depot/projects/trustedbsd/mac/sys/sys/proc.h#24 (text+ko) ==== @@ -645,6 +645,7 @@ #define PS_SWAPPING 0x00200 /* Process is being swapped. */ #define PS_NEEDSIGCHK 0x02000 /* Process may need signal delivery. */ #define PS_SWAPPINGIN 0x04000 /* Swapin in progress. */ +#define PS_MACPEND 0x08000 /* ast()-based MAC event pending */ /* used only in legacy conversion code */ #define SIDL 1 /* Process being created by fork. */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message