|
|
1.1 root 1: /*
2: * Copyright (c) 1994 The University of Utah and
3: * the Computer Systems Laboratory (CSL). All rights reserved.
4: *
5: * Permission to use, copy, modify and distribute this software is hereby
6: * granted provided that (1) source code retains these copyright, permission,
7: * and disclaimer notices, and (2) redistributions including binaries
8: * reproduce the notices in supporting documentation, and (3) all advertising
9: * materials mentioning features or use of this software display the following
10: * acknowledgement: ``This product includes software developed by the
11: * Computer Systems Laboratory at the University of Utah.''
12: *
13: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
14: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
15: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16: *
17: * CSL requests users of this software to return to [email protected] any
18: * improvements that they make and grant CSL redistribution rights.
19: *
20: */
21:
22: #ifdef MIGRATING_THREADS
23:
1.1.1.2 root 24: #include <kern/printf.h>
1.1 root 25: #include <mach/kern_return.h>
26: #include <mach/port.h>
27: #include <mach/rpc.h>
28: #include <mach/notify.h>
29: #include <mach/mach_param.h>
30: #include <mach/vm_param.h>
31: #include <mach/vm_prot.h>
32: #include <kern/task.h>
33: #include <kern/act.h>
34: #include <vm/vm_map.h>
35: #include <vm/vm_kern.h>
36: #include <vm/vm_user.h>
37: #include <ipc/ipc_entry.h>
38: #include <ipc/ipc_space.h>
39: #include <ipc/ipc_object.h>
40: #include <ipc/ipc_notify.h>
41: #include <ipc/ipc_port.h>
42: #include <ipc/ipc_pset.h>
43: #include <ipc/ipc_right.h>
44:
45: #undef DEBUG_MPRC
46:
47: /*
48: * XXX need to identify if one endpoint of an RPC is the kernel to
49: * ensure proper port name translation (or lack of). This is bogus.
50: */
51: #define ISKERNELACT(act) ((act)->task == kernel_task)
52:
53: /*
54: * Copy the indicated port from the task associated with the source
55: * activation into the task associated with the destination activation.
56: *
57: * XXX on errors we should probably clear the portp to avoid leaking
58: * info to the other side.
59: */
60: kern_return_t
1.1.1.3 ! root 61: mach_port_rpc_copy(
! 62: struct rpc_port_desc *portp,
! 63: struct Act *sact,
! 64: struct Act *dact)
1.1 root 65: {
66: ipc_space_t sspace, dspace;
67: mach_msg_type_name_t tname;
68: ipc_object_t iname;
69: kern_return_t kr;
70:
71: #ifdef DEBUG_MPRC
72: printf("m_p_rpc_copy(portp=%x/%x, sact=%x, dact=%x): ",
73: portp->name, portp->msgt_name, sact, dact);
74: #endif
75: sspace = sact->task->itk_space;
76: dspace = dact->task->itk_space;
77: if (sspace == IS_NULL || dspace == IS_NULL) {
78: #ifdef DEBUG_MPRC
79: printf("bogus src (%x) or dst (%x) space\n", sspace, dspace);
80: #endif
81: return KERN_INVALID_TASK;
82: }
83:
84: if (!MACH_MSG_TYPE_PORT_ANY(portp->msgt_name)) {
85: #ifdef DEBUG_MPRC
86: printf("invalid port type\n");
87: #endif
88: return KERN_INVALID_VALUE;
89: }
90:
91: if (ISKERNELACT(sact)) {
92: iname = (ipc_object_t) portp->name;
93: ipc_object_copyin_from_kernel(iname, portp->msgt_name);
94: kr = KERN_SUCCESS;
95: } else {
96: kr = ipc_object_copyin(sspace, portp->name, portp->msgt_name,
97: &iname);
98: }
99: if (kr != KERN_SUCCESS) {
100: #ifdef DEBUG_MPRC
101: printf("copyin returned %x\n", kr);
102: #endif
103: return kr;
104: }
105:
106: tname = ipc_object_copyin_type(portp->msgt_name);
107: if (!IO_VALID(iname)) {
108: portp->name = (mach_port_t) iname;
109: portp->msgt_name = tname;
110: #ifdef DEBUG_MPRC
111: printf("iport %x invalid\n", iname);
112: #endif
113: return KERN_SUCCESS;
114: }
115:
116: if (ISKERNELACT(dact)) {
117: portp->name = (mach_port_t) iname;
118: kr = KERN_SUCCESS;
119: } else {
120: kr = ipc_object_copyout(dspace, iname, tname, TRUE,
121: &portp->name);
122: }
123: if (kr != KERN_SUCCESS) {
124: ipc_object_destroy(iname, tname);
125:
126: if (kr == KERN_INVALID_CAPABILITY)
127: portp->name = MACH_PORT_DEAD;
128: else {
129: portp->name = MACH_PORT_NULL;
130: #ifdef DEBUG_MPRC
131: printf("copyout iport %x returned %x\n", iname);
132: #endif
133: return kr;
134: }
135: }
136:
137: portp->msgt_name = tname;
138: #ifdef DEBUG_MPRC
139: printf("portp=%x/%x, iname=%x\n", portp->name, portp->msgt_name, iname);
140: #endif
141: return KERN_SUCCESS;
142: }
143:
144: kern_return_t
1.1.1.3 ! root 145: mach_port_rpc_sig(const ipc_space_t space, const char *name, const char *buffer, unsigned int buflen)
1.1 root 146: {
147: return KERN_FAILURE;
148: }
149:
150: #endif /* MIGRATING_THREADS */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.