From owner-p4-projects@FreeBSD.ORG Tue Mar 7 16:39:58 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 0068916A423; Tue, 7 Mar 2006 16:39:57 +0000 (GMT) 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 C702E16A420 for ; Tue, 7 Mar 2006 16:39:57 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 285EB43D55 for ; Tue, 7 Mar 2006 16:39:57 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k27GdvMu005810 for ; Tue, 7 Mar 2006 16:39:57 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k27GduY9005807 for perforce@freebsd.org; Tue, 7 Mar 2006 16:39:56 GMT (envelope-from millert@freebsd.org) Date: Tue, 7 Mar 2006 16:39:56 GMT Message-Id: <200603071639.k27GduY9005807@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 92917 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: Tue, 07 Mar 2006 16:39:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=92917 Change 92917 by millert@millert_ibook on 2006/03/07 16:39:26 Convert mach_get_task_label() and mach_get_task_label_text() to take ipc_space_t not task_t and add sanity check for space being IS_NULL. Fixes a panic when the port passed in is not a task port. Affected files ... .. //depot/projects/trustedbsd/sedarwin7/src/darwin/xnu/osfmk/kern/security.c#6 edit .. //depot/projects/trustedbsd/sedarwin7/src/darwin/xnu/osfmk/mach/security.defs#7 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin7/src/darwin/xnu/osfmk/kern/security.c#6 (text+ko) ==== @@ -32,13 +32,16 @@ kern_return_t mach_get_task_label( - task_t t, + ipc_space_t space, mach_port_name_t *outlabel) { - ipc_labelh_t lh = t->label; - ipc_space_t space = t->itk_space; kern_return_t kr; + ipc_labelh_t lh; + + if (space == IS_NULL || space->is_task == NULL) + return KERN_INVALID_TASK; + lh = space->is_task->label; ip_lock(lh->lh_port); lh->lh_port->ip_mscount++; lh->lh_port->ip_srights++; @@ -55,16 +58,21 @@ return (KERN_SUCCESS); } +kern_return_t -kern_return_t mach_get_task_label_text( - task_t t, + ipc_space_t space, labelstr_t policies, labelstr_t outl) { - tasklabel_lock(t); - mac_externalize_task_label(&t->maclabel, policies, outl, 512, 0); - tasklabel_unlock(t); + + if (space == IS_NULL) + return KERN_INVALID_TASK; + + tasklabel_lock(space->is_task); + mac_externalize_task_label(&space->is_task->maclabel, policies, outl, + 512, 0); + tasklabel_unlock(space->is_task); return KERN_SUCCESS; } ==== //depot/projects/trustedbsd/sedarwin7/src/darwin/xnu/osfmk/mach/security.defs#7 (text+ko) ==== @@ -23,7 +23,7 @@ @return Standard MiG return values (0 for success) */ -routine mach_get_task_label(task : task_t; +routine mach_get_task_label(task : ipc_space_t; out label : mach_port_name_t); /** @@ -38,7 +38,7 @@ @return Standard MiG return values (0 for success) */ -routine mach_get_task_label_text(task : task_t; +routine mach_get_task_label_text(task : ipc_space_t; policies : labelstr_t; out label : labelstr_t);