--- Gnu-Mach/ipc/ipc_right.c 2020/09/02 04:45:04 1.1.1.3 +++ Gnu-Mach/ipc/ipc_right.c 2020/09/02 04:47:17 1.1.1.4 @@ -331,10 +331,10 @@ ipc_right_dncancel( */ boolean_t -ipc_right_inuse(space, name, entry) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; +ipc_right_inuse( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits = entry->ie_bits; @@ -359,11 +359,11 @@ ipc_right_inuse(space, name, entry) */ boolean_t -ipc_right_check(space, port, name, entry) - ipc_space_t space; - ipc_port_t port; - mach_port_t name; - ipc_entry_t entry; +ipc_right_check( + ipc_space_t space, + ipc_port_t port, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits; @@ -697,10 +697,10 @@ ipc_right_destroy( */ kern_return_t -ipc_right_dealloc(space, name, entry) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; +ipc_right_dealloc( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry) { ipc_entry_bits_t bits = entry->ie_bits; mach_port_type_t type = IE_BITS_TYPE(bits); @@ -874,12 +874,12 @@ ipc_right_dealloc(space, name, entry) */ kern_return_t -ipc_right_delta(space, name, entry, right, delta) - ipc_space_t space; - mach_port_t name; - ipc_entry_t entry; - mach_port_right_t right; - mach_port_delta_t delta; +ipc_right_delta( + ipc_space_t space, + mach_port_t name, + ipc_entry_t entry, + mach_port_right_t right, + mach_port_delta_t delta) { ipc_entry_bits_t bits = entry->ie_bits; @@ -1432,6 +1432,12 @@ ipc_right_copyin( port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + + /* + * Clear the protected payload field to retain + * the behavior of mach_msg. + */ + ipc_port_flag_protected_payload_clear(port); ip_unlock(port); *objectp = (ipc_object_t) port; @@ -1932,6 +1938,12 @@ ipc_right_copyout( port->ip_receiver_name = name; port->ip_receiver = space; + /* + * Clear the protected payload field to retain + * the behavior of mach_msg. + */ + ipc_port_flag_protected_payload_clear(port); + assert((bits & MACH_PORT_TYPE_RECEIVE) == 0); if (bits & MACH_PORT_TYPE_SEND) {