diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-08-18 11:32:15 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-14 14:45:05 +0200 |
commit | 428d6a971cffaba40b0f8ea5f66c3a3e0c853e88 (patch) | |
tree | 40a755b03bea045582e25fbdb46d431ba581662d /ipc/ipc_port.c | |
parent | 22778b589af94261c2d8d0665220770d0b56d1a8 (diff) |
ipc: fix locking issues
* ipc/ipc_port.h (struct ipc_port): Document locking exception.
* ipc/ipc_port.c (ipc_port_destroy): Avoid accessing `port's fields
without the lock.
(ipc_port_alloc_special): Lock `port'.
* ipc/mach_msg.c (mach_msg_trap): Avoid using
`ipc_port_flag_protected_payload' on unlocked port.
* ipc/ipc_kmsg.c (ipc_kmsg_copyout_header): Likewise.
Diffstat (limited to 'ipc/ipc_port.c')
-rw-r--r-- | ipc/ipc_port.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c index 86a4ee2..4e4ad59 100644 --- a/ipc/ipc_port.c +++ b/ipc/ipc_port.c @@ -694,11 +694,13 @@ ipc_port_destroy( port->ip_object.io_bits &= ~IO_BITS_ACTIVE; port->ip_timestamp = ipc_port_timestamp(); + + nsrequest = port->ip_nsrequest; + dnrequests = port->ip_dnrequests; + ip_unlock(port); /* throw away no-senders request */ - - nsrequest = port->ip_nsrequest; if (nsrequest != IP_NULL) ipc_notify_send_once(nsrequest); /* consumes ref */ @@ -725,8 +727,6 @@ ipc_port_destroy( imq_unlock(mqueue); /* generate dead-name notifications */ - - dnrequests = port->ip_dnrequests; if (dnrequests != IPR_NULL) { ipc_table_size_t its = dnrequests->ipr_size; ipc_table_elems_t size = its->its_size; @@ -1183,6 +1183,7 @@ ipc_port_alloc_special(ipc_space_t space) return IP_NULL; ip_lock_init(port); + ip_lock(port); port->ip_references = 1; port->ip_object.io_bits = io_makebits(TRUE, IOT_PORT, 0); @@ -1198,7 +1199,7 @@ ipc_port_alloc_special(ipc_space_t space) */ ipc_port_init(port, space, (mach_port_t)port); - + ip_unlock(port); return port; } |