Annotation of kernel/ipc/ipc_notify.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:  * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990  
                     27:  * Open Software Foundation, Inc. 
                     28:  *  
                     29:  * Permission to use, copy, modify, and distribute this software and 
                     30:  * its documentation for any purpose and without fee is hereby granted, 
                     31:  * provided that the above copyright notice appears in all copies and 
                     32:  * that both the copyright notice and this permission notice appear in 
                     33:  * supporting documentation, and that the name of ("OSF") or Open Software 
                     34:  * Foundation not be used in advertising or publicity pertaining to 
                     35:  * distribution of the software without specific, written prior permission. 
                     36:  *  
                     37:  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
                     38:  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
                     39:  * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY 
                     40:  * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
                     41:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
                     42:  * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING 
                     43:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE 
                     44:  */
                     45: /*
                     46:  * OSF Research Institute MK6.1 (unencumbered) 1/31/1995
                     47:  */
                     48: /* 
                     49:  * Mach Operating System
                     50:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
                     51:  * All Rights Reserved.
                     52:  * 
                     53:  * Permission to use, copy, modify and distribute this software and its
                     54:  * documentation is hereby granted, provided that both the copyright
                     55:  * notice and this permission notice appear in all copies of the
                     56:  * software, derivative works or modified versions, and any portions
                     57:  * thereof, and that both notices appear in supporting documentation.
                     58:  * 
                     59:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     60:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     61:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     62:  * 
                     63:  * Carnegie Mellon requests users of this software to return to
                     64:  * 
                     65:  *  Software Distribution Coordinator  or  [email protected]
                     66:  *  School of Computer Science
                     67:  *  Carnegie Mellon University
                     68:  *  Pittsburgh PA 15213-3890
                     69:  * 
                     70:  * any improvements or extensions that they make and grant Carnegie Mellon
                     71:  * the rights to redistribute these changes.
                     72:  */
                     73: /*
                     74:  *     File:   ipc/ipc_notify.c
                     75:  *     Author: Rich Draves
                     76:  *     Date:   1989
                     77:  *
                     78:  *     Notification-sending functions.
                     79:  */
                     80: 
                     81: #import <mach/features.h>
                     82: 
                     83: #include <mach/port.h>
                     84: #include <mach/message.h>
                     85: #include <mach/notify.h>
                     86: #include <kern/assert.h>
                     87: #include <ipc/ipc_kmsg.h>
                     88: #include <ipc/ipc_mqueue.h>
                     89: #include <ipc/ipc_notify.h>
                     90: #include <ipc/ipc_port.h>
                     91: 
                     92: #include <ipc/ipc_machdep.h>
                     93: 
                     94: /*
                     95:  * Forward declarations
                     96:  */
                     97: void ipc_notify_init_port_deleted(
                     98:        mach_port_deleted_notification_t        *n);
                     99: 
                    100: void ipc_notify_init_port_destroyed(
                    101:        mach_port_destroyed_notification_t      *n);
                    102: 
                    103: void ipc_notify_init_no_senders(
                    104:        mach_no_senders_notification_t          *n);
                    105: 
                    106: void ipc_notify_init_send_once(
                    107:        mach_send_once_notification_t           *n);
                    108: 
                    109: void ipc_notify_init_dead_name(
                    110:        mach_dead_name_notification_t           *n);
                    111: 
                    112: mach_port_deleted_notification_t       ipc_notify_port_deleted_template;
                    113: mach_port_destroyed_notification_t     ipc_notify_port_destroyed_template;
                    114: mach_no_senders_notification_t         ipc_notify_no_senders_template;
                    115: mach_send_once_notification_t          ipc_notify_send_once_template;
                    116: mach_dead_name_notification_t          ipc_notify_dead_name_template;
                    117: 
                    118: #if    MACH_IPC_COMPAT
                    119: notification_t                 ipc_notify_port_deleted_compat_template;
                    120: notification_t                 ipc_notify_msg_accepted_compat_template;
                    121: notification_t                 ipc_notify_port_destroyed_compat_template;
                    122: 
                    123: /*
                    124:  *     When notification messages are received via the old
                    125:  *     msg_receive trap, the msg_type field should contain
                    126:  *     MSG_TYPE_EMERGENCY.  We arrange for this by putting
                    127:  *     MSG_TYPE_EMERGENCY into msgh_reserved, which
                    128:  *     ipc_kmsg_copyout_compat copies to msg_type.
                    129:  */
                    130: 
                    131: #define NOTIFY_MSGH_RESERVED   MSG_TYPE_EMERGENCY
                    132: #endif /* MACH_IPC_COMPAT */
                    133: 
                    134: /*
                    135:  *     Routine:        ipc_notify_init_port_deleted
                    136:  *     Purpose:
                    137:  *             Initialize a template for port-deleted notifications.
                    138:  */
                    139: 
                    140: void
                    141: ipc_notify_init_port_deleted(
                    142:        mach_port_deleted_notification_t        *n)
                    143: {
                    144:        mach_msg_header_t *m = &n->not_header;
                    145: 
                    146:        m->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0);
                    147:        m->msgh_local_port = MACH_PORT_NULL;
                    148:        m->msgh_remote_port = MACH_PORT_NULL;
                    149:        m->msgh_id = MACH_NOTIFY_PORT_DELETED;
                    150:        m->msgh_size = ((int)sizeof *n) - sizeof(mach_msg_format_0_trailer_t);
                    151: 
                    152:        n->NDR = NDR_record;
                    153:        n->not_port = MACH_PORT_NULL;
                    154: }
                    155: 
                    156: #if    MACH_IPC_COMPAT
                    157: void
                    158: ipc_notify_init_port_deleted_compat(
                    159:        notification_t          *n)
                    160: {
                    161:        mach_msg_header_t *m = (mach_msg_header_t *)&n->notify_header;
                    162:        mach_msg_type_t *t = (mach_msg_type_t *)&n->notify_type;
                    163: 
                    164:        m->msgh_bits = MACH_MSGH_BITS_OLD_FORMAT |
                    165:                MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0);
                    166:        m->msgh_size = sizeof *n;
                    167:        m->msgh_reserved = NOTIFY_MSGH_RESERVED;
                    168:        m->msgh_local_port = MACH_PORT_NULL;
                    169:        m->msgh_remote_port = MACH_PORT_NULL;
                    170:        m->msgh_id = MACH_NOTIFY_PORT_DELETED;
                    171: 
                    172:        t->msgt_name = MACH_MSG_TYPE_PORT_NAME;
                    173:        t->msgt_size = PORT_T_SIZE_IN_BITS;
                    174:        t->msgt_number = 1;
                    175:        t->msgt_inline = TRUE;
                    176:        t->msgt_longform = FALSE;
                    177:        t->msgt_deallocate = FALSE;
                    178:        t->msgt_unused = 0;
                    179: 
                    180:        n->notify_port = PORT_NULL;
                    181: }
                    182: #endif /* MACH_IPC_COMPAT */
                    183: 
                    184: /*
                    185:  *     Routine:        ipc_notify_init_msg_accepted
                    186:  *     Purpose:
                    187:  *             Initialize a template for msg-accepted notifications.
                    188:  */
                    189: 
                    190: #if    MACH_IPC_COMPAT
                    191: void
                    192: ipc_notify_init_msg_accepted_compat(
                    193:        notification_t          *n)
                    194: {
                    195:        mach_msg_header_t *m = (mach_msg_header_t *)&n->notify_header;
                    196:        mach_msg_type_t *t = (mach_msg_type_t *)&n->notify_type;
                    197: 
                    198:        m->msgh_bits = MACH_MSGH_BITS_OLD_FORMAT |
                    199:                MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0);
                    200:        m->msgh_size = sizeof *n;
                    201:        m->msgh_reserved = NOTIFY_MSGH_RESERVED;
                    202:        m->msgh_local_port = MACH_PORT_NULL;
                    203:        m->msgh_remote_port = MACH_PORT_NULL;
                    204:        m->msgh_id = MACH_NOTIFY_MSG_ACCEPTED;
                    205: 
                    206:        t->msgt_name = MACH_MSG_TYPE_PORT_NAME;
                    207:        t->msgt_size = PORT_T_SIZE_IN_BITS;
                    208:        t->msgt_number = 1;
                    209:        t->msgt_inline = TRUE;
                    210:        t->msgt_longform = FALSE;
                    211:        t->msgt_deallocate = FALSE;
                    212:        t->msgt_unused = 0;
                    213: 
                    214:        n->notify_port = PORT_NULL;
                    215: }
                    216: #endif /* MACH_IPC_COMPAT */
                    217: 
                    218: /*
                    219:  *     Routine:        ipc_notify_init_port_destroyed
                    220:  *     Purpose:
                    221:  *             Initialize a template for port-destroyed notifications.
                    222:  */
                    223: 
                    224: void
                    225: ipc_notify_init_port_destroyed(
                    226:        mach_port_destroyed_notification_t      *n)
                    227: {
                    228:        mach_msg_header_t *m = &n->not_header;
                    229: 
                    230:        m->msgh_bits = MACH_MSGH_BITS_COMPLEX |
                    231:                MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0);
                    232:        m->msgh_local_port = MACH_PORT_NULL;
                    233:        m->msgh_remote_port = MACH_PORT_NULL;
                    234:        m->msgh_id = MACH_NOTIFY_PORT_DESTROYED;
                    235:        m->msgh_size = ((int)sizeof *n) - sizeof(mach_msg_format_0_trailer_t);
                    236: 
                    237:        n->not_body.msgh_descriptor_count = 1;
                    238:        n->not_port.disposition = MACH_MSG_TYPE_PORT_RECEIVE;
                    239:        n->not_port.name = MACH_PORT_NULL;
                    240:        n->not_port.type = MACH_MSG_PORT_DESCRIPTOR;
                    241: }
                    242: 
                    243: #if    MACH_IPC_COMPAT
                    244: void
                    245: ipc_notify_init_port_destroyed_compat(
                    246:        notification_t           *n)
                    247: {
                    248:        mach_msg_header_t *m = (mach_msg_header_t *)&n->notify_header;
                    249:        mach_msg_type_t *t = (mach_msg_type_t *)&n->notify_type;
                    250: 
                    251:        m->msgh_bits = MACH_MSGH_BITS_OLD_FORMAT | MACH_MSGH_BITS_COMPLEX |
                    252:                MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0);
                    253:        m->msgh_size = sizeof *n;
                    254:        m->msgh_reserved = NOTIFY_MSGH_RESERVED;
                    255:        m->msgh_local_port = MACH_PORT_NULL;
                    256:        m->msgh_remote_port = MACH_PORT_NULL;
                    257:        m->msgh_id = MACH_NOTIFY_PORT_DESTROYED;
                    258: 
                    259:        t->msgt_name = MACH_MSG_TYPE_PORT_RECEIVE;
                    260:        t->msgt_size = PORT_T_SIZE_IN_BITS;
                    261:        t->msgt_number = 1;
                    262:        t->msgt_inline = TRUE;
                    263:        t->msgt_longform = FALSE;
                    264:        t->msgt_deallocate = FALSE;
                    265:        t->msgt_unused = 0;
                    266: 
                    267:        n->notify_port = PORT_NULL;
                    268: }
                    269: #endif /* MACH_IPC_COMPAT */
                    270: 
                    271: /*
                    272:  *     Routine:        ipc_notify_init_no_senders
                    273:  *     Purpose:
                    274:  *             Initialize a template for no-senders notifications.
                    275:  */
                    276: 
                    277: void
                    278: ipc_notify_init_no_senders(
                    279:        mach_no_senders_notification_t  *n)
                    280: {
                    281:        mach_msg_header_t *m = &n->not_header;
                    282: 
                    283:        m->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0);
                    284:        m->msgh_local_port = MACH_PORT_NULL;
                    285:        m->msgh_remote_port = MACH_PORT_NULL;
                    286:        m->msgh_id = MACH_NOTIFY_NO_SENDERS;
                    287:        m->msgh_size = ((int)sizeof *n) - sizeof(mach_msg_format_0_trailer_t);
                    288: 
                    289:        n->NDR = NDR_record;
                    290:        n->not_count = 0;
                    291: }
                    292: 
                    293: /*
                    294:  *     Routine:        ipc_notify_init_send_once
                    295:  *     Purpose:
                    296:  *             Initialize a template for send-once notifications.
                    297:  */
                    298: 
                    299: void
                    300: ipc_notify_init_send_once(
                    301:        mach_send_once_notification_t   *n)
                    302: {
                    303:        mach_msg_header_t *m = &n->not_header;
                    304: 
                    305:        m->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0);
                    306:        m->msgh_local_port = MACH_PORT_NULL;
                    307:        m->msgh_remote_port = MACH_PORT_NULL;
                    308:        m->msgh_id = MACH_NOTIFY_SEND_ONCE;
                    309:        m->msgh_size = ((int)sizeof *n) - sizeof(mach_msg_format_0_trailer_t);
                    310: }
                    311: 
                    312: /*
                    313:  *     Routine:        ipc_notify_init_dead_name
                    314:  *     Purpose:
                    315:  *             Initialize a template for dead-name notifications.
                    316:  */
                    317: 
                    318: void
                    319: ipc_notify_init_dead_name(
                    320:        mach_dead_name_notification_t   *n)
                    321: {
                    322:        mach_msg_header_t *m = &n->not_header;
                    323: 
                    324:        m->msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0);
                    325:        m->msgh_local_port = MACH_PORT_NULL;
                    326:        m->msgh_remote_port = MACH_PORT_NULL;
                    327:        m->msgh_id = MACH_NOTIFY_DEAD_NAME;
                    328:        m->msgh_size = ((int)sizeof *n) - sizeof(mach_msg_format_0_trailer_t);
                    329: 
                    330:        n->NDR = NDR_record;
                    331:        n->not_port = MACH_PORT_NULL;
                    332: }
                    333: 
                    334: /*
                    335:  *     Routine:        ipc_notify_init
                    336:  *     Purpose:
                    337:  *             Initialize the notification subsystem.
                    338:  */
                    339: 
                    340: void
                    341: ipc_notify_init(void)
                    342: {
                    343:        ipc_notify_init_port_deleted(&ipc_notify_port_deleted_template);
                    344:        ipc_notify_init_port_destroyed(&ipc_notify_port_destroyed_template);
                    345:        ipc_notify_init_no_senders(&ipc_notify_no_senders_template);
                    346:        ipc_notify_init_send_once(&ipc_notify_send_once_template);
                    347:        ipc_notify_init_dead_name(&ipc_notify_dead_name_template);
                    348: #if    MACH_IPC_COMPAT
                    349:        ipc_notify_init_msg_accepted_compat(
                    350:                                &ipc_notify_msg_accepted_compat_template);
                    351:        ipc_notify_init_port_deleted_compat(
                    352:                                &ipc_notify_port_deleted_compat_template);
                    353:        ipc_notify_init_port_destroyed_compat(
                    354:                                &ipc_notify_port_destroyed_compat_template);
                    355: #endif /* MACH_IPC_COMPAT */
                    356: }
                    357: 
                    358: /*
                    359:  *     Routine:        ipc_notify_port_deleted
                    360:  *     Purpose:
                    361:  *             Send a port-deleted notification.
                    362:  *     Conditions:
                    363:  *             Nothing locked.
                    364:  *             Consumes a ref/soright for port.
                    365:  */
                    366: 
                    367: void
                    368: ipc_notify_port_deleted(
                    369:        ipc_port_t      port,
                    370:        mach_port_t     name)
                    371: {
                    372:        ipc_kmsg_t kmsg;
                    373:        mach_port_deleted_notification_t *n;
                    374: 
                    375:        kmsg = ikm_alloc(sizeof *n);
                    376:        if (kmsg == IKM_NULL) {
                    377:                printf("dropped port-deleted (0x%08x, 0x%x)\n", port, name);
                    378:                ipc_port_release_sonce(port);
                    379:                return;
                    380:        }
                    381: 
                    382:        ikm_init(kmsg, sizeof *n);
                    383:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    384: 
                    385:        n = (mach_port_deleted_notification_t *) &kmsg->ikm_header;
                    386:        *n = ipc_notify_port_deleted_template;
                    387: 
                    388:        n->not_header.msgh_remote_port = (mach_port_t) port;
                    389:        n->not_port = name;
                    390: 
                    391:        ipc_mqueue_send_always(kmsg);
                    392: }
                    393: 
                    394: /*
                    395:  *     Routine:        ipc_notify_port_destroyed
                    396:  *     Purpose:
                    397:  *             Send a port-destroyed notification.
                    398:  *     Conditions:
                    399:  *             Nothing locked.
                    400:  *             Consumes a ref/soright for port.
                    401:  *             Consumes a ref for right, which should be a receive right
                    402:  *             prepped for placement into a message.  (In-transit,
                    403:  *             or in-limbo if a circularity was detected.)
                    404:  */
                    405: 
                    406: void
                    407: ipc_notify_port_destroyed(
                    408:        ipc_port_t      port,
                    409:        ipc_port_t      right)
                    410: {
                    411:        ipc_kmsg_t kmsg;
                    412:        mach_port_destroyed_notification_t *n;
                    413: 
                    414:        kmsg = ikm_alloc(sizeof *n);
                    415:        if (kmsg == IKM_NULL) {
                    416:                printf("dropped port-destroyed (0x%08x, 0x%08x)\n",
                    417:                       port, right);
                    418:                ipc_port_release_sonce(port);
                    419:                ipc_port_release_receive(right);
                    420:                return;
                    421:        }
                    422: 
                    423:        ikm_init(kmsg, sizeof *n);
                    424:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    425: 
                    426:        n = (mach_port_destroyed_notification_t *) &kmsg->ikm_header;
                    427:        *n = ipc_notify_port_destroyed_template;
                    428: 
                    429:        n->not_header.msgh_remote_port = (mach_port_t) port;
                    430:        n->not_port.name = (mach_port_t)right;
                    431: 
                    432:        ipc_mqueue_send_always(kmsg);
                    433: }
                    434: 
                    435: /*
                    436:  *     Routine:        ipc_notify_no_senders
                    437:  *     Purpose:
                    438:  *             Send a no-senders notification.
                    439:  *     Conditions:
                    440:  *             Nothing locked.
                    441:  *             Consumes a ref/soright for port.
                    442:  */
                    443: 
                    444: void
                    445: ipc_notify_no_senders(
                    446:        ipc_port_t              port,
                    447:        mach_port_mscount_t     mscount)
                    448: {
                    449:        ipc_kmsg_t kmsg;
                    450:        mach_no_senders_notification_t *n;
                    451: 
                    452:        kmsg = ikm_alloc(sizeof *n);
                    453:        if (kmsg == IKM_NULL) {
                    454:                printf("dropped no-senders (0x%08x, %u)\n", port, mscount);
                    455:                ipc_port_release_sonce(port);
                    456:                return;
                    457:        }
                    458: 
                    459:        ikm_init(kmsg, sizeof *n);
                    460:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    461: 
                    462:        n = (mach_no_senders_notification_t *) &kmsg->ikm_header;
                    463:        *n = ipc_notify_no_senders_template;
                    464: 
                    465:        n->not_header.msgh_remote_port = (mach_port_t) port;
                    466:        n->not_count = mscount;
                    467: 
                    468:        ipc_mqueue_send_always(kmsg);
                    469: }
                    470: 
                    471: /*
                    472:  *     Routine:        ipc_notify_send_once
                    473:  *     Purpose:
                    474:  *             Send a send-once notification.
                    475:  *     Conditions:
                    476:  *             Nothing locked.
                    477:  *             Consumes a ref/soright for port.
                    478:  */
                    479: 
                    480: void
                    481: ipc_notify_send_once(
                    482:        ipc_port_t      port)
                    483: {
                    484:        ipc_kmsg_t kmsg;
                    485:        mach_send_once_notification_t *n;
                    486: 
                    487:        kmsg = ikm_alloc(sizeof *n);
                    488:        if (kmsg == IKM_NULL) {
                    489:                printf("dropped send-once (0x%08x)\n", port);
                    490:                ipc_port_release_sonce(port);
                    491:                return;
                    492:        }
                    493: 
                    494:        ikm_init(kmsg, sizeof *n);
                    495:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    496: 
                    497:        n = (mach_send_once_notification_t *) &kmsg->ikm_header;
                    498:        *n = ipc_notify_send_once_template;
                    499: 
                    500:         n->not_header.msgh_remote_port = (mach_port_t) port;
                    501: 
                    502:        ipc_mqueue_send_always(kmsg);
                    503: }
                    504: 
                    505: /*
                    506:  *     Routine:        ipc_notify_dead_name
                    507:  *     Purpose:
                    508:  *             Send a dead-name notification.
                    509:  *     Conditions:
                    510:  *             Nothing locked.
                    511:  *             Consumes a ref/soright for port.
                    512:  */
                    513: 
                    514: void
                    515: ipc_notify_dead_name(
                    516:        ipc_port_t      port,
                    517:        mach_port_t     name)
                    518: {
                    519:        ipc_kmsg_t kmsg;
                    520:        mach_dead_name_notification_t *n;
                    521: 
                    522:        kmsg = ikm_alloc(sizeof *n);
                    523:        if (kmsg == IKM_NULL) {
                    524:                printf("dropped dead-name (0x%08x, 0x%x)\n", port, name);
                    525:                ipc_port_release_sonce(port);
                    526:                return;
                    527:        }
                    528: 
                    529:        ikm_init(kmsg, sizeof *n);
                    530:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    531: 
                    532:        n = (mach_dead_name_notification_t *) &kmsg->ikm_header;
                    533:        *n = ipc_notify_dead_name_template;
                    534: 
                    535:        n->not_header.msgh_remote_port = (mach_port_t) port;
                    536:        n->not_port = name;
                    537: 
                    538:        ipc_mqueue_send_always(kmsg);
                    539: }
                    540: 
                    541: #if    MACH_IPC_COMPAT
                    542: 
                    543: /*
                    544:  *     Routine:        ipc_notify_port_deleted_compat
                    545:  *     Purpose:
                    546:  *             Send a port-deleted notification.
                    547:  *             Sends it to a send right instead of a send-once right.
                    548:  *     Conditions:
                    549:  *             Nothing locked.
                    550:  *             Consumes a ref/sright for port.
                    551:  */
                    552: 
                    553: void
                    554: ipc_notify_port_deleted_compat(
                    555:        ipc_port_t      port,
                    556:        mach_port_t     name)
                    557: {
                    558:        ipc_kmsg_t kmsg;
                    559:        notification_t *n;
                    560: 
                    561:        kmsg = ikm_alloc(sizeof *n);
                    562:        if (kmsg == IKM_NULL) {
                    563:                printf("dropped port-deleted-compat (0x%08x, 0x%x)\n",
                    564:                       port, name);
                    565:                ipc_port_release_send(port);
                    566:                return;
                    567:        }
                    568: 
                    569:        ikm_init(kmsg, sizeof *n);
                    570:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    571: 
                    572:        n = (notification_t *) &kmsg->ikm_header;
                    573:        *n = ipc_notify_port_deleted_compat_template;
                    574: 
                    575:        kmsg->ikm_header.msgh_remote_port = (mach_port_t) port;
                    576: 
                    577:        n->notify_port = (port_t)name;
                    578: 
                    579:        ipc_mqueue_send_always(kmsg);
                    580: }
                    581: 
                    582: /*
                    583:  *     Routine:        ipc_notify_msg_accepted_compat
                    584:  *     Purpose:
                    585:  *             Send a msg-accepted notification.
                    586:  *             Sends it to a send right instead of a send-once right.
                    587:  *     Conditions:
                    588:  *             Nothing locked.
                    589:  *             Consumes a ref/sright for port.
                    590:  */
                    591: 
                    592: void
                    593: ipc_notify_msg_accepted_compat(
                    594:        ipc_port_t      port,
                    595:        mach_port_t     name)
                    596: {
                    597:        ipc_kmsg_t kmsg;
                    598:        notification_t *n;
                    599: 
                    600:        kmsg = ikm_alloc(sizeof *n);
                    601:        if (kmsg == IKM_NULL) {
                    602:                printf("dropped msg-accepted-compat (0x%08x, 0x%x)\n",
                    603:                       port, name);
                    604:                ipc_port_release_send(port);
                    605:                return;
                    606:        }
                    607: 
                    608:        ikm_init(kmsg, sizeof *n);
                    609:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    610: 
                    611:        n = (notification_t *) &kmsg->ikm_header;
                    612:        *n = ipc_notify_msg_accepted_compat_template;
                    613: 
                    614:        kmsg->ikm_header.msgh_remote_port = (mach_port_t) port;
                    615: 
                    616:        n->notify_port = (port_t)name;
                    617: 
                    618:        ipc_mqueue_send_always(kmsg);
                    619: }
                    620: 
                    621: /*
                    622:  *     Routine:        ipc_notify_port_destroyed_compat
                    623:  *     Purpose:
                    624:  *             Send a port-destroyed notification.
                    625:  *             Sends it to a send right instead of a send-once right.
                    626:  *     Conditions:
                    627:  *             Nothing locked.
                    628:  *             Consumes a ref/sright for port.
                    629:  *             Consumes a ref for right, which should be a receive right
                    630:  *             prepped for placement into a message.  (In-transit,
                    631:  *             or in-limbo if a circularity was detected.)
                    632:  */
                    633: 
                    634: void
                    635: ipc_notify_port_destroyed_compat(
                    636:        ipc_port_t      port,
                    637:        ipc_port_t      right)
                    638: {
                    639:        ipc_kmsg_t kmsg;
                    640:        notification_t *n;
                    641: 
                    642:        kmsg = ikm_alloc(sizeof *n);
                    643:        if (kmsg == IKM_NULL) {
                    644:                printf("dropped port-destroyed-compat (0x%08x, 0x%08x)\n",
                    645:                       port, right);
                    646:                ipc_port_release_send(port);
                    647:                ipc_port_release_receive(right);
                    648:                return;
                    649:        }
                    650: 
                    651:        ikm_init(kmsg, sizeof *n);
                    652:        kmsg->ikm_sender = KERNEL_SECURITY_ID_VALUE;
                    653: 
                    654:        n = (notification_t *) &kmsg->ikm_header;
                    655:        *n = ipc_notify_port_destroyed_compat_template;
                    656: 
                    657:        kmsg->ikm_header.msgh_remote_port = (mach_port_t) port;
                    658: 
                    659:        n->notify_port = (port_t) right;
                    660: 
                    661:        ipc_mqueue_send_always(kmsg);
                    662: }
                    663: 
                    664: #endif /* MACH_IPC_COMPAT */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.