Clear the protected payload when a receive port is moved from one ipc space to another. This is done to retain the old behavior of mach_msg, so that a port name is sent in the msgh_local_port field. If the new owner of that receive right wishes to use the protected payload mechanism, it has to be explicitly set with mach_port_set_protected_payload.
* ipc/ipc_right.c (ipc_right_copyin): Clear the payload when moving a receive port. (ipc_right_copyout): Likewise. * ipc/ipc_port.c (ipc_port_destroy): Likewise. * ipc/ipc_object.c (ipc_object_copyin_from_kernel): Likewise. --- ipc/ipc_object.c | 1 + ipc/ipc_port.c | 1 + ipc/ipc_right.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index 982bd4e..59f5a67 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -481,6 +481,7 @@ ipc_object_copyin_from_kernel( port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + port->ip_protected_payload = 0; ip_unlock(port); break; } diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 4e6d598..4051746 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -635,6 +635,7 @@ ipc_port_destroy( /* make port be in limbo */ port->ip_receiver_name = MACH_PORT_NULL; port->ip_destination = IP_NULL; + port->ip_protected_payload = 0; ip_unlock(port); if (!ipc_port_check_circularity(port, pdrequest)) { diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 41fe3de..1edbb47 100644 --- a/ipc/ipc_right.c +++ b/ipc/ipc_right.c @@ -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. + */ + port->ip_protected_payload = 0; 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. + */ + port->ip_protected_payload = 0; + assert((bits & MACH_PORT_TYPE_RECEIVE) == 0); if (bits & MACH_PORT_TYPE_SEND) { -- 1.8.5.2