]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ipc_host.c
b68bd0a0902888f5410960603055d742c6f2e94b
[apple/xnu.git] / osfmk / kern / ipc_host.c
1 /*
2 * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58
59 /*
60 * kern/ipc_host.c
61 *
62 * Routines to implement host ports.
63 */
64 #include <mach/message.h>
65 #include <mach/mach_traps.h>
66 #include <mach/mach_host_server.h>
67 #include <mach/host_priv_server.h>
68 #include <kern/host.h>
69 #include <kern/processor.h>
70 #include <kern/task.h>
71 #include <kern/thread.h>
72 #include <kern/ipc_host.h>
73 #include <kern/ipc_kobject.h>
74 #include <kern/misc_protos.h>
75 #include <kern/spl.h>
76 #include <ipc/ipc_port.h>
77 #include <ipc/ipc_space.h>
78
79 #if CONFIG_MACF
80 #include <security/mac_mach_internal.h>
81 #endif
82
83 /*
84 * Forward declarations
85 */
86
87 boolean_t
88 ref_pset_port_locked(
89 ipc_port_t port, boolean_t matchn, processor_set_t *ppset);
90
91 /*
92 * ipc_host_init: set up various things.
93 */
94
95 extern lck_grp_t host_notify_lock_grp;
96 extern lck_attr_t host_notify_lock_attr;
97
98 void ipc_host_init(void)
99 {
100 ipc_port_t port;
101 int i;
102
103 lck_mtx_init(&realhost.lock, &host_notify_lock_grp, &host_notify_lock_attr);
104
105 /*
106 * Allocate and set up the two host ports.
107 */
108 port = ipc_port_alloc_kernel();
109 if (port == IP_NULL)
110 panic("ipc_host_init");
111
112 ipc_kobject_set(port, (ipc_kobject_t) &realhost, IKOT_HOST_SECURITY);
113 kernel_set_special_port(&realhost, HOST_SECURITY_PORT,
114 ipc_port_make_send(port));
115
116 port = ipc_port_alloc_kernel();
117 if (port == IP_NULL)
118 panic("ipc_host_init");
119
120 ipc_kobject_set(port, (ipc_kobject_t) &realhost, IKOT_HOST);
121 kernel_set_special_port(&realhost, HOST_PORT,
122 ipc_port_make_send(port));
123
124 port = ipc_port_alloc_kernel();
125 if (port == IP_NULL)
126 panic("ipc_host_init");
127
128 ipc_kobject_set(port, (ipc_kobject_t) &realhost, IKOT_HOST_PRIV);
129 kernel_set_special_port(&realhost, HOST_PRIV_PORT,
130 ipc_port_make_send(port));
131
132 /* the rest of the special ports will be set up later */
133
134 for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
135 realhost.exc_actions[i].port = IP_NULL;
136 realhost.exc_actions[i].label = NULL;
137 /* The mac framework is not yet initialized, so we defer
138 * initializing the labels to later, when they are set
139 * for the first time. */
140 }/* for */
141
142 /*
143 * Set up ipc for default processor set.
144 */
145 ipc_pset_init(&pset0);
146 ipc_pset_enable(&pset0);
147
148 /*
149 * And for master processor
150 */
151 ipc_processor_init(master_processor);
152 ipc_processor_enable(master_processor);
153 }
154
155 /*
156 * Routine: host_self_trap [mach trap]
157 * Purpose:
158 * Give the caller send rights for his own host port.
159 * Conditions:
160 * Nothing locked.
161 * Returns:
162 * MACH_PORT_NULL if there are any resource failures
163 * or other errors.
164 */
165
166 mach_port_name_t
167 host_self_trap(
168 __unused struct host_self_trap_args *args)
169 {
170 ipc_port_t sright;
171 mach_port_name_t name;
172
173 sright = ipc_port_copy_send(current_task()->itk_host);
174 name = ipc_port_copyout_send(sright, current_space());
175 return name;
176 }
177
178 /*
179 * ipc_processor_init:
180 *
181 * Initialize ipc access to processor by allocating port.
182 */
183
184 void
185 ipc_processor_init(
186 processor_t processor)
187 {
188 ipc_port_t port;
189
190 port = ipc_port_alloc_kernel();
191 if (port == IP_NULL)
192 panic("ipc_processor_init");
193 processor->processor_self = port;
194 }
195
196 /*
197 * ipc_processor_enable:
198 *
199 * Enable ipc control of processor by setting port object.
200 */
201 void
202 ipc_processor_enable(
203 processor_t processor)
204 {
205 ipc_port_t myport;
206
207 myport = processor->processor_self;
208 ipc_kobject_set(myport, (ipc_kobject_t) processor, IKOT_PROCESSOR);
209 }
210
211 /*
212 * ipc_pset_init:
213 *
214 * Initialize ipc control of a processor set by allocating its ports.
215 */
216
217 void
218 ipc_pset_init(
219 processor_set_t pset)
220 {
221 ipc_port_t port;
222
223 port = ipc_port_alloc_kernel();
224 if (port == IP_NULL)
225 panic("ipc_pset_init");
226 pset->pset_self = port;
227
228 port = ipc_port_alloc_kernel();
229 if (port == IP_NULL)
230 panic("ipc_pset_init");
231 pset->pset_name_self = port;
232 }
233
234 /*
235 * ipc_pset_enable:
236 *
237 * Enable ipc access to a processor set.
238 */
239 void
240 ipc_pset_enable(
241 processor_set_t pset)
242 {
243 ipc_kobject_set(pset->pset_self, (ipc_kobject_t) pset, IKOT_PSET);
244 ipc_kobject_set(pset->pset_name_self, (ipc_kobject_t) pset, IKOT_PSET_NAME);
245 }
246
247 /*
248 * processor_set_default:
249 *
250 * Return ports for manipulating default_processor set.
251 */
252 kern_return_t
253 processor_set_default(
254 host_t host,
255 processor_set_t *pset)
256 {
257 if (host == HOST_NULL)
258 return(KERN_INVALID_ARGUMENT);
259
260 *pset = &pset0;
261
262 return (KERN_SUCCESS);
263 }
264
265 /*
266 * Routine: convert_port_to_host
267 * Purpose:
268 * Convert from a port to a host.
269 * Doesn't consume the port ref; the host produced may be null.
270 * Conditions:
271 * Nothing locked.
272 */
273
274 host_t
275 convert_port_to_host(
276 ipc_port_t port)
277 {
278 host_t host = HOST_NULL;
279
280 if (IP_VALID(port)) {
281 if (ip_kotype(port) == IKOT_HOST ||
282 ip_kotype(port) == IKOT_HOST_PRIV) {
283 host = (host_t) port->ip_kobject;
284 assert(ip_active(port));
285 }
286 }
287 return host;
288 }
289
290 /*
291 * Routine: convert_port_to_host_priv
292 * Purpose:
293 * Convert from a port to a host.
294 * Doesn't consume the port ref; the host produced may be null.
295 * Conditions:
296 * Nothing locked.
297 */
298
299 host_t
300 convert_port_to_host_priv(
301 ipc_port_t port)
302 {
303 host_t host = HOST_NULL;
304
305 if (IP_VALID(port)) {
306 ip_lock(port);
307 if (ip_active(port) &&
308 (ip_kotype(port) == IKOT_HOST_PRIV))
309 host = (host_t) port->ip_kobject;
310 ip_unlock(port);
311 }
312
313 return host;
314 }
315
316 /*
317 * Routine: convert_port_to_processor
318 * Purpose:
319 * Convert from a port to a processor.
320 * Doesn't consume the port ref;
321 * the processor produced may be null.
322 * Conditions:
323 * Nothing locked.
324 */
325
326 processor_t
327 convert_port_to_processor(
328 ipc_port_t port)
329 {
330 processor_t processor = PROCESSOR_NULL;
331
332 if (IP_VALID(port)) {
333 ip_lock(port);
334 if (ip_active(port) &&
335 (ip_kotype(port) == IKOT_PROCESSOR))
336 processor = (processor_t) port->ip_kobject;
337 ip_unlock(port);
338 }
339
340 return processor;
341 }
342
343 /*
344 * Routine: convert_port_to_pset
345 * Purpose:
346 * Convert from a port to a pset.
347 * Doesn't consume the port ref; produces a pset ref,
348 * which may be null.
349 * Conditions:
350 * Nothing locked.
351 */
352
353 processor_set_t
354 convert_port_to_pset(
355 ipc_port_t port)
356 {
357 boolean_t r;
358 processor_set_t pset = PROCESSOR_SET_NULL;
359
360 r = FALSE;
361 while (!r && IP_VALID(port)) {
362 ip_lock(port);
363 r = ref_pset_port_locked(port, FALSE, &pset);
364 /* port unlocked */
365 }
366 return pset;
367 }
368
369 /*
370 * Routine: convert_port_to_pset_name
371 * Purpose:
372 * Convert from a port to a pset.
373 * Doesn't consume the port ref; produces a pset ref,
374 * which may be null.
375 * Conditions:
376 * Nothing locked.
377 */
378
379 processor_set_name_t
380 convert_port_to_pset_name(
381 ipc_port_t port)
382 {
383 boolean_t r;
384 processor_set_t pset = PROCESSOR_SET_NULL;
385
386 r = FALSE;
387 while (!r && IP_VALID(port)) {
388 ip_lock(port);
389 r = ref_pset_port_locked(port, TRUE, &pset);
390 /* port unlocked */
391 }
392 return pset;
393 }
394
395 boolean_t
396 ref_pset_port_locked(ipc_port_t port, boolean_t matchn, processor_set_t *ppset)
397 {
398 processor_set_t pset;
399
400 pset = PROCESSOR_SET_NULL;
401 if (ip_active(port) &&
402 ((ip_kotype(port) == IKOT_PSET) ||
403 (matchn && (ip_kotype(port) == IKOT_PSET_NAME)))) {
404 pset = (processor_set_t) port->ip_kobject;
405 }
406
407 *ppset = pset;
408 ip_unlock(port);
409
410 return (TRUE);
411 }
412
413 /*
414 * Routine: convert_host_to_port
415 * Purpose:
416 * Convert from a host to a port.
417 * Produces a naked send right which may be invalid.
418 * Conditions:
419 * Nothing locked.
420 */
421
422 ipc_port_t
423 convert_host_to_port(
424 host_t host)
425 {
426 ipc_port_t port;
427
428 host_get_host_port(host, &port);
429 return port;
430 }
431
432 /*
433 * Routine: convert_processor_to_port
434 * Purpose:
435 * Convert from a processor to a port.
436 * Produces a naked send right which may be invalid.
437 * Processors are not reference counted, so nothing to release.
438 * Conditions:
439 * Nothing locked.
440 */
441
442 ipc_port_t
443 convert_processor_to_port(
444 processor_t processor)
445 {
446 ipc_port_t port = processor->processor_self;
447
448 if (port != IP_NULL)
449 port = ipc_port_make_send(port);
450 return port;
451 }
452
453 /*
454 * Routine: convert_pset_to_port
455 * Purpose:
456 * Convert from a pset to a port.
457 * Produces a naked send right which may be invalid.
458 * Processor sets are not reference counted, so nothing to release.
459 * Conditions:
460 * Nothing locked.
461 */
462
463 ipc_port_t
464 convert_pset_to_port(
465 processor_set_t pset)
466 {
467 ipc_port_t port = pset->pset_self;
468
469 if (port != IP_NULL)
470 port = ipc_port_make_send(port);
471
472 return port;
473 }
474
475 /*
476 * Routine: convert_pset_name_to_port
477 * Purpose:
478 * Convert from a pset to a port.
479 * Produces a naked send right which may be invalid.
480 * Processor sets are not reference counted, so nothing to release.
481 * Conditions:
482 * Nothing locked.
483 */
484
485 ipc_port_t
486 convert_pset_name_to_port(
487 processor_set_name_t pset)
488 {
489 ipc_port_t port = pset->pset_name_self;
490
491 if (port != IP_NULL)
492 port = ipc_port_make_send(port);
493
494 return port;
495 }
496
497 /*
498 * Routine: convert_port_to_host_security
499 * Purpose:
500 * Convert from a port to a host security.
501 * Doesn't consume the port ref; the port produced may be null.
502 * Conditions:
503 * Nothing locked.
504 */
505
506 host_t
507 convert_port_to_host_security(
508 ipc_port_t port)
509 {
510 host_t host = HOST_NULL;
511
512 if (IP_VALID(port)) {
513 ip_lock(port);
514 if (ip_active(port) &&
515 (ip_kotype(port) == IKOT_HOST_SECURITY))
516 host = (host_t) port->ip_kobject;
517 ip_unlock(port);
518 }
519
520 return host;
521 }
522
523 /*
524 * Routine: host_set_exception_ports [kernel call]
525 * Purpose:
526 * Sets the host exception port, flavor and
527 * behavior for the exception types specified by the mask.
528 * There will be one send right per exception per valid
529 * port.
530 * Conditions:
531 * Nothing locked. If successful, consumes
532 * the supplied send right.
533 * Returns:
534 * KERN_SUCCESS Changed the special port.
535 * KERN_INVALID_ARGUMENT The host_priv is not valid,
536 * Illegal mask bit set.
537 * Illegal exception behavior
538 */
539 kern_return_t
540 host_set_exception_ports(
541 host_priv_t host_priv,
542 exception_mask_t exception_mask,
543 ipc_port_t new_port,
544 exception_behavior_t new_behavior,
545 thread_state_flavor_t new_flavor)
546 {
547 int i;
548 ipc_port_t old_port[EXC_TYPES_COUNT];
549
550 if (host_priv == HOST_PRIV_NULL) {
551 return KERN_INVALID_ARGUMENT;
552 }
553
554 if (exception_mask & ~EXC_MASK_VALID) {
555 return KERN_INVALID_ARGUMENT;
556 }
557
558 if (IP_VALID(new_port)) {
559 switch (new_behavior & ~MACH_EXCEPTION_CODES) {
560 case EXCEPTION_DEFAULT:
561 case EXCEPTION_STATE:
562 case EXCEPTION_STATE_IDENTITY:
563 break;
564 default:
565 return KERN_INVALID_ARGUMENT;
566 }
567 }
568
569 /*
570 * Check the validity of the thread_state_flavor by calling the
571 * VALID_THREAD_STATE_FLAVOR architecture dependent macro defined in
572 * osfmk/mach/ARCHITECTURE/thread_status.h
573 */
574 if (new_flavor != 0 && !VALID_THREAD_STATE_FLAVOR(new_flavor))
575 return (KERN_INVALID_ARGUMENT);
576
577 #if CONFIG_MACF
578 if (mac_task_check_set_host_exception_ports(current_task(), exception_mask) != 0)
579 return KERN_NO_ACCESS;
580 #endif
581
582 assert(host_priv == &realhost);
583
584 host_lock(host_priv);
585
586 for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
587 #if CONFIG_MACF
588 if (host_priv->exc_actions[i].label == NULL) {
589 // Lazy initialization (see ipc_port_init).
590 mac_exc_action_label_init(host_priv->exc_actions + i);
591 }
592 #endif
593
594 if ((exception_mask & (1 << i))
595 #if CONFIG_MACF
596 && mac_exc_action_label_update(current_task(), host_priv->exc_actions + i) == 0
597 #endif
598 ) {
599 old_port[i] = host_priv->exc_actions[i].port;
600
601 host_priv->exc_actions[i].port =
602 ipc_port_copy_send(new_port);
603 host_priv->exc_actions[i].behavior = new_behavior;
604 host_priv->exc_actions[i].flavor = new_flavor;
605 } else {
606 old_port[i] = IP_NULL;
607 }
608 }/* for */
609
610 /*
611 * Consume send rights without any lock held.
612 */
613 host_unlock(host_priv);
614 for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++)
615 if (IP_VALID(old_port[i]))
616 ipc_port_release_send(old_port[i]);
617 if (IP_VALID(new_port)) /* consume send right */
618 ipc_port_release_send(new_port);
619
620 return KERN_SUCCESS;
621 }
622
623 /*
624 * Routine: host_get_exception_ports [kernel call]
625 * Purpose:
626 * Clones a send right for each of the host's exception
627 * ports specified in the mask and returns the behaviour
628 * and flavor of said port.
629 *
630 * Returns upto [in} CountCnt elements.
631 *
632 * Conditions:
633 * Nothing locked.
634 * Returns:
635 * KERN_SUCCESS Extracted a send right.
636 * KERN_INVALID_ARGUMENT Invalid host_priv specified,
637 * Invalid special port,
638 * Illegal mask bit set.
639 * KERN_FAILURE The thread is dead.
640 */
641 kern_return_t
642 host_get_exception_ports(
643 host_priv_t host_priv,
644 exception_mask_t exception_mask,
645 exception_mask_array_t masks,
646 mach_msg_type_number_t * CountCnt,
647 exception_port_array_t ports,
648 exception_behavior_array_t behaviors,
649 thread_state_flavor_array_t flavors )
650 {
651 unsigned int i, j, count;
652
653 if (host_priv == HOST_PRIV_NULL)
654 return KERN_INVALID_ARGUMENT;
655
656 if (exception_mask & ~EXC_MASK_VALID) {
657 return KERN_INVALID_ARGUMENT;
658 }
659
660 assert (host_priv == &realhost);
661
662 host_lock(host_priv);
663
664 count = 0;
665
666 for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
667 #if CONFIG_MACF
668 if (host_priv->exc_actions[i].label == NULL) {
669 // Lazy initialization (see ipc_port_init).
670 mac_exc_action_label_init(host_priv->exc_actions + i);
671 }
672 #endif
673
674 if (exception_mask & (1 << i)) {
675 for (j = 0; j < count; j++) {
676 /*
677 * search for an identical entry, if found
678 * set corresponding mask for this exception.
679 */
680 if (host_priv->exc_actions[i].port == ports[j] &&
681 host_priv->exc_actions[i].behavior == behaviors[j]
682 && host_priv->exc_actions[i].flavor == flavors[j])
683 {
684 masks[j] |= (1 << i);
685 break;
686 }
687 }/* for */
688 if (j == count) {
689 masks[j] = (1 << i);
690 ports[j] =
691 ipc_port_copy_send(host_priv->exc_actions[i].port);
692 behaviors[j] = host_priv->exc_actions[i].behavior;
693 flavors[j] = host_priv->exc_actions[i].flavor;
694 count++;
695 if (count > *CountCnt) {
696 break;
697 }
698 }
699 }
700 }/* for */
701 host_unlock(host_priv);
702
703 *CountCnt = count;
704 return KERN_SUCCESS;
705 }
706
707 kern_return_t
708 host_swap_exception_ports(
709 host_priv_t host_priv,
710 exception_mask_t exception_mask,
711 ipc_port_t new_port,
712 exception_behavior_t new_behavior,
713 thread_state_flavor_t new_flavor,
714 exception_mask_array_t masks,
715 mach_msg_type_number_t * CountCnt,
716 exception_port_array_t ports,
717 exception_behavior_array_t behaviors,
718 thread_state_flavor_array_t flavors )
719 {
720 unsigned int i,
721 j,
722 count;
723 ipc_port_t old_port[EXC_TYPES_COUNT];
724
725 if (host_priv == HOST_PRIV_NULL)
726 return KERN_INVALID_ARGUMENT;
727
728 if (exception_mask & ~EXC_MASK_VALID) {
729 return KERN_INVALID_ARGUMENT;
730 }
731
732 if (IP_VALID(new_port)) {
733 switch (new_behavior) {
734 case EXCEPTION_DEFAULT:
735 case EXCEPTION_STATE:
736 case EXCEPTION_STATE_IDENTITY:
737 break;
738 default:
739 return KERN_INVALID_ARGUMENT;
740 }
741 }
742
743 if (new_flavor != 0 && !VALID_THREAD_STATE_FLAVOR(new_flavor))
744 return (KERN_INVALID_ARGUMENT);
745
746 #if CONFIG_MACF
747 if (mac_task_check_set_host_exception_ports(current_task(), exception_mask) != 0)
748 return KERN_NO_ACCESS;
749 #endif /* CONFIG_MACF */
750
751 host_lock(host_priv);
752
753 assert(EXC_TYPES_COUNT > FIRST_EXCEPTION);
754 for (count=0, i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT && count < *CountCnt; i++) {
755 #if CONFIG_MACF
756 if (host_priv->exc_actions[i].label == NULL) {
757 // Lazy initialization (see ipc_port_init).
758 mac_exc_action_label_init(host_priv->exc_actions + i);
759 }
760 #endif
761
762 if ((exception_mask & (1 << i))
763 #if CONFIG_MACF
764 && mac_exc_action_label_update(current_task(), host_priv->exc_actions + i) == 0
765 #endif
766 ) {
767 for (j = 0; j < count; j++) {
768 /*
769 * search for an identical entry, if found
770 * set corresponding mask for this exception.
771 */
772 if (host_priv->exc_actions[i].port == ports[j] &&
773 host_priv->exc_actions[i].behavior == behaviors[j]
774 && host_priv->exc_actions[i].flavor == flavors[j])
775 {
776 masks[j] |= (1 << i);
777 break;
778 }
779 }/* for */
780 if (j == count) {
781 masks[j] = (1 << i);
782 ports[j] =
783 ipc_port_copy_send(host_priv->exc_actions[i].port);
784 behaviors[j] = host_priv->exc_actions[i].behavior;
785 flavors[j] = host_priv->exc_actions[i].flavor;
786 count++;
787 }
788 old_port[i] = host_priv->exc_actions[i].port;
789 host_priv->exc_actions[i].port =
790 ipc_port_copy_send(new_port);
791 host_priv->exc_actions[i].behavior = new_behavior;
792 host_priv->exc_actions[i].flavor = new_flavor;
793 } else
794 old_port[i] = IP_NULL;
795 }/* for */
796 host_unlock(host_priv);
797
798 /*
799 * Consume send rights without any lock held.
800 */
801 while (--i >= FIRST_EXCEPTION) {
802 if (IP_VALID(old_port[i]))
803 ipc_port_release_send(old_port[i]);
804 }
805
806 if (IP_VALID(new_port)) /* consume send right */
807 ipc_port_release_send(new_port);
808 *CountCnt = count;
809
810 return KERN_SUCCESS;
811 }