From d565bf2f784ce1203e77306d05eade03933bc523 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 21 Nov 2013 16:50:49 +0100 Subject: ipc: add protected payload Add a field ip_protected_payload and a flag ip_has_protected_payload to struct ipc_port. 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 again. * ipc/ipc_port.h (struct ipc_port): Add field ip_protected_payload. (ipc_port_set_protected_payload): Add function declaration. (ipc_port_clear_protected_payload): Likewise. (ipc_port_flag_protected_payload): Add accessor for the protected payload flag. (ipc_port_flag_protected_payload_set): Likewise. (ipc_port_flag_protected_payload_clear): Likewise. * ipc/ipc_port.c (ipc_port_init): Initialize protected payload. (ipc_port_print): Print protected_payload. (ipc_port_set_protected_payload): New function. (ipc_port_clear_protected_payload): Likewise. (ipc_port_destroy): Clear the payload when moving a receive port. * ipc/ipc_right.c (ipc_right_copyin): Likewise. (ipc_right_copyout): Likewise. * ipc/ipc_object.c (ipc_object_copyin_from_kernel): Likewise. * ipc/ipc_object.h (IO_BITS_PROTECTED_PAYLOAD): New bitmask. (IO_BITS_OTYPE): Adjust accordingly. --- ipc/ipc_right.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ipc/ipc_right.c') diff --git a/ipc/ipc_right.c b/ipc/ipc_right.c index 77a68ce..503eb1f 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. + */ + 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) { -- cgit v1.2.3