From owner-trustedbsd-cvs@FreeBSD.ORG Mon Jan 22 16:13:28 2007 Return-Path: X-Original-To: trustedbsd-cvs@freebsd.org Delivered-To: trustedbsd-cvs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0C76F16A4D0 for ; Mon, 22 Jan 2007 16:13:28 +0000 (UTC) (envelope-from owner-perforce@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 705BC13C4BE for ; Mon, 22 Jan 2007 16:13:24 +0000 (UTC) (envelope-from owner-perforce@freebsd.org) Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by cyrus.watson.org (Postfix) with ESMTP id 78F8A48EF2 for ; Mon, 22 Jan 2007 11:13:20 -0500 (EST) Received: from hub.freebsd.org (hub.freebsd.org [69.147.83.54]) by mx2.freebsd.org (Postfix) with ESMTP id CFBB0CF921; Mon, 22 Jan 2007 16:13:01 +0000 (GMT) (envelope-from owner-perforce@freebsd.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id C573416A408; Mon, 22 Jan 2007 16:13:01 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8B2FA16A401 for ; Mon, 22 Jan 2007 16:13:01 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 6DEB113C44B for ; Mon, 22 Jan 2007 16:13:01 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0MGD1ut029121 for ; Mon, 22 Jan 2007 16:13:01 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0MGD1Ue029118 for perforce@freebsd.org; Mon, 22 Jan 2007 16:13:01 GMT (envelope-from millert@freebsd.org) Date: Mon, 22 Jan 2007 16:13:01 GMT Message-Id: <200701221613.l0MGD1Ue029118@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 113355 for review X-BeenThere: trustedbsd-cvs@FreeBSD.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: TrustedBSD CVS and Perforce commit message list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2007 16:13:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=113355 Change 113355 by millert@millert_macbook on 2007/01/22 16:12:25 Back out thread labels (which were really just references to the parent task's label handle). It was a proof of concept that doesn't work well with the current label handle model. A real solution requires reference-counted labels that may be modified in-place. I have a design to do that but it is not likely to happen any time soon. Affected files ... .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/ipc/ipc_labelh.c#11 edit .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/ipc/ipc_labelh.h#6 edit .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/task.c#10 edit .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/thread.c#4 edit .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/thread.h#4 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/ipc/ipc_labelh.c#11 (text+ko) ==== @@ -149,7 +149,7 @@ * Returned label handle is locked. */ ipc_labelh_t -labelh_modify(ipc_labelh_t old, int keepold) +labelh_modify(ipc_labelh_t old) { ipc_labelh_t lh; ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/ipc/ipc_labelh.h#6 (text+ko) ==== @@ -45,7 +45,7 @@ void labelh_destroy(ipc_port_t port); ipc_labelh_t labelh_duplicate(ipc_labelh_t old); -ipc_labelh_t labelh_modify(ipc_labelh_t old, int keepold); +ipc_labelh_t labelh_modify(ipc_labelh_t old); ipc_labelh_t labelh_new(int canblock); kern_return_t labelh_new_user(ipc_space_t, struct label *, mach_port_name_t *); void labelh_release(ipc_labelh_t lh); ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/task.c#10 (text+ko) ==== @@ -1696,35 +1696,10 @@ struct label *pl, struct task *task) { - thread_t thread; - ipc_labelh_t oldlabel; tasklabel_lock(task); - oldlabel = task->label; - - /* - * For each thread in the task, release a reference to the label - * handle in the thread if it matches the parent's. - * XXX - do we need to hold the task while this is going on? - */ - queue_iterate(&task->threads, thread, thread_t, task_threads) { - if (thread->label == oldlabel) - lh_release(oldlabel); - } - task->label = labelh_modify(task->label, 1); + task->label = labelh_modify(task->label); mac_task_label_update(pl, &task->maclabel); - /* - * Replace the old label in the task's threads with the new one. - */ - queue_iterate(&task->threads, thread, thread_t, task_threads) { - if (thread->label == oldlabel) { - thread->label = task->label; - lh_reference(task->label); - } - } - /* Free old label if it is no longer in use. */ - if (task->label != oldlabel) - lh_check_unlock(oldlabel); tasklabel_unlock(task); ip_lock(task->itk_self); mac_port_label_update_cred(pl, &task->itk_self->ip_label); @@ -1737,35 +1712,10 @@ void *arg, void (*f) (struct label *l, void *arg)) { - thread_t thread; - ipc_labelh_t oldlabel; tasklabel_lock(task); - oldlabel = task->label; - - /* - * For each thread in the task, release a reference to the label - * handle in the thread if it matches the parent's. - * XXX - do we need to hold the task while this is going on? - */ - queue_iterate(&task->threads, thread, thread_t, task_threads) { - if (thread->label == oldlabel) - lh_release(oldlabel); - } - task->label = labelh_modify(task->label, 1); + task->label = labelh_modify(task->label); (*f)(&task->maclabel, arg); - /* - * Replace the old label in the task's threads with the new one. - */ - queue_iterate(&task->threads, thread, thread_t, task_threads) { - if (thread->label == oldlabel) { - thread->label = task->label; - lh_reference(task->label); - } - } - /* Free old label if it is no longer in use. */ - if (task->label != oldlabel) - lh_check_unlock(oldlabel); tasklabel_unlock(task); } ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/thread.c#4 (text+ko) ==== @@ -391,10 +391,6 @@ machine_thread_destroy(thread); -#ifdef MAC - labelh_release(task->label); -#endif - zfree(thread_zone, thread); } @@ -669,11 +665,6 @@ new_thread->pri_shift = new_thread->processor_set->pri_shift; compute_priority(new_thread, FALSE); -#ifdef MAC - labelh_reference(parent_task->label); - new_thread->label = parent_task->label; -#endif - new_thread->active = TRUE; *out_thread = new_thread; ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/osfmk/kern/thread.h#4 (text+ko) ==== @@ -122,9 +122,7 @@ #include #include #include -#include -#include #include #include @@ -357,10 +355,6 @@ #ifdef MACH_BSD void *uthread; #endif - -#ifdef MAC - ipc_labelh_t label; -#endif }; #define ith_state saved.receive.state