|
|
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
61: mach_port_rpc_copy(portp, sact, dact)
62: struct rpc_port_desc *portp;
63: struct Act *sact, *dact;
64: {
65: ipc_space_t sspace, dspace;
66: mach_msg_type_name_t tname;
67: ipc_object_t iname;
68: kern_return_t kr;
69:
70: #ifdef DEBUG_MPRC
71: printf("m_p_rpc_copy(portp=%x/%x, sact=%x, dact=%x): ",
72: portp->name, portp->msgt_name, sact, dact);
73: #endif
74: sspace = sact->task->itk_space;
75: dspace = dact->task->itk_space;
76: if (sspace == IS_NULL || dspace == IS_NULL) {
77: #ifdef DEBUG_MPRC
78: printf("bogus src (%x) or dst (%x) space\n", sspace, dspace);
79: #endif
80: return KERN_INVALID_TASK;
81: }
82:
83: if (!MACH_MSG_TYPE_PORT_ANY(portp->msgt_name)) {
84: #ifdef DEBUG_MPRC
85: printf("invalid port type\n");
86: #endif
87: return KERN_INVALID_VALUE;
88: }
89:
90: if (ISKERNELACT(sact)) {
91: iname = (ipc_object_t) portp->name;
92: ipc_object_copyin_from_kernel(iname, portp->msgt_name);
93: kr = KERN_SUCCESS;
94: } else {
95: kr = ipc_object_copyin(sspace, portp->name, portp->msgt_name,
96: &iname);
97: }
98: if (kr != KERN_SUCCESS) {
99: #ifdef DEBUG_MPRC
100: printf("copyin returned %x\n", kr);
101: #endif
102: return kr;
103: }
104:
105: tname = ipc_object_copyin_type(portp->msgt_name);
106: if (!IO_VALID(iname)) {
107: portp->name = (mach_port_t) iname;
108: portp->msgt_name = tname;
109: #ifdef DEBUG_MPRC
110: printf("iport %x invalid\n", iname);
111: #endif
112: return KERN_SUCCESS;
113: }
114:
115: if (ISKERNELACT(dact)) {
116: portp->name = (mach_port_t) iname;
117: kr = KERN_SUCCESS;
118: } else {
119: kr = ipc_object_copyout(dspace, iname, tname, TRUE,
120: &portp->name);
121: }
122: if (kr != KERN_SUCCESS) {
123: ipc_object_destroy(iname, tname);
124:
125: if (kr == KERN_INVALID_CAPABILITY)
126: portp->name = MACH_PORT_DEAD;
127: else {
128: portp->name = MACH_PORT_NULL;
129: #ifdef DEBUG_MPRC
130: printf("copyout iport %x returned %x\n", iname);
131: #endif
132: return kr;
133: }
134: }
135:
136: portp->msgt_name = tname;
137: #ifdef DEBUG_MPRC
138: printf("portp=%x/%x, iname=%x\n", portp->name, portp->msgt_name, iname);
139: #endif
140: return KERN_SUCCESS;
141: }
142:
143: kern_return_t
144: mach_port_rpc_sig(space, name, buffer, buflen)
145: {
146: return KERN_FAILURE;
147: }
148:
149: #endif /* MIGRATING_THREADS */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.