1*2c2f96dcSApple OSS Distributions #include <darwintest.h>
2*2c2f96dcSApple OSS Distributions #include <TargetConditionals.h>
3*2c2f96dcSApple OSS Distributions #include <mach/mach.h>
4*2c2f96dcSApple OSS Distributions #include <stdlib.h>
5*2c2f96dcSApple OSS Distributions #include <sys/sysctl.h>
6*2c2f96dcSApple OSS Distributions #include <unistd.h>
7*2c2f96dcSApple OSS Distributions #include <darwintest_multiprocess.h>
8*2c2f96dcSApple OSS Distributions #include <spawn.h>
9*2c2f96dcSApple OSS Distributions #include <spawn_private.h>
10*2c2f96dcSApple OSS Distributions #include <libproc_internal.h>
11*2c2f96dcSApple OSS Distributions #include <signal.h>
12*2c2f96dcSApple OSS Distributions #include <string.h>
13*2c2f96dcSApple OSS Distributions
14*2c2f96dcSApple OSS Distributions #include <err.h>
15*2c2f96dcSApple OSS Distributions #include <stdio.h>
16*2c2f96dcSApple OSS Distributions #include <sysexits.h>
17*2c2f96dcSApple OSS Distributions #include <stdbool.h>
18*2c2f96dcSApple OSS Distributions
19*2c2f96dcSApple OSS Distributions #include "rnServer.h" // generated by MIG from rnserver.defs
20*2c2f96dcSApple OSS Distributions
21*2c2f96dcSApple OSS Distributions #include <dispatch/dispatch.h>
22*2c2f96dcSApple OSS Distributions #include <dispatch/private.h> // dispatch_mig_server()
23*2c2f96dcSApple OSS Distributions #include <servers/bootstrap.h>
24*2c2f96dcSApple OSS Distributions #include <libproc_internal.h> // proc*cpumon*()
25*2c2f96dcSApple OSS Distributions
26*2c2f96dcSApple OSS Distributions T_GLOBAL_META(
27*2c2f96dcSApple OSS Distributions T_META_NAMESPACE("xnu.ipc"),
28*2c2f96dcSApple OSS Distributions T_META_RUN_CONCURRENTLY(TRUE),
29*2c2f96dcSApple OSS Distributions T_META_RADAR_COMPONENT_NAME("xnu"),
30*2c2f96dcSApple OSS Distributions T_META_RADAR_COMPONENT_VERSION("IPC"));
31*2c2f96dcSApple OSS Distributions
32*2c2f96dcSApple OSS Distributions #define MAX_ARGV 5
33*2c2f96dcSApple OSS Distributions
34*2c2f96dcSApple OSS Distributions extern char **environ;
35*2c2f96dcSApple OSS Distributions static mach_port_t resource_notify_port = MACH_PORT_NULL;
36*2c2f96dcSApple OSS Distributions
37*2c2f96dcSApple OSS Distributions T_DECL(test_port_table_setting_limits,
38*2c2f96dcSApple OSS Distributions "Allocate ports upto hard limit",
39*2c2f96dcSApple OSS Distributions T_META_IGNORECRASHES(".*port_table_limits_client.*"),
40*2c2f96dcSApple OSS Distributions T_META_CHECK_LEAKS(false))
41*2c2f96dcSApple OSS Distributions {
42*2c2f96dcSApple OSS Distributions char *test_prog_name = "./port_table_limits_client";
43*2c2f96dcSApple OSS Distributions char *child_args[MAX_ARGV];
44*2c2f96dcSApple OSS Distributions int child_pid;
45*2c2f96dcSApple OSS Distributions posix_spawnattr_t attrs;
46*2c2f96dcSApple OSS Distributions int err;
47*2c2f96dcSApple OSS Distributions
48*2c2f96dcSApple OSS Distributions #if TARGET_OS_BRIDGE
49*2c2f96dcSApple OSS Distributions T_SKIP("Not running on target platforms");
50*2c2f96dcSApple OSS Distributions #endif
51*2c2f96dcSApple OSS Distributions
52*2c2f96dcSApple OSS Distributions /* Initialize posix_spawn attributes */
53*2c2f96dcSApple OSS Distributions posix_spawnattr_init(&attrs);
54*2c2f96dcSApple OSS Distributions
55*2c2f96dcSApple OSS Distributions err = posix_spawnattr_set_portlimits_ext(&attrs, 3000, 5000);
56*2c2f96dcSApple OSS Distributions T_EXPECT_POSIX_SUCCESS(err, "posix_spawnattr_set_portlimits_ext");
57*2c2f96dcSApple OSS Distributions
58*2c2f96dcSApple OSS Distributions child_args[0] = test_prog_name;
59*2c2f96dcSApple OSS Distributions child_args[1] = "3000"; //soft limit
60*2c2f96dcSApple OSS Distributions child_args[2] = "5000"; //hard limit
61*2c2f96dcSApple OSS Distributions child_args[3] = "1"; //test num
62*2c2f96dcSApple OSS Distributions child_args[4] = NULL;
63*2c2f96dcSApple OSS Distributions
64*2c2f96dcSApple OSS Distributions err = posix_spawn(&child_pid, child_args[0], NULL, &attrs, child_args, environ);
65*2c2f96dcSApple OSS Distributions T_EXPECT_POSIX_SUCCESS(err, "posix_spawn port_table_limits_client");
66*2c2f96dcSApple OSS Distributions
67*2c2f96dcSApple OSS Distributions int child_status;
68*2c2f96dcSApple OSS Distributions /* Wait for child and check for exception */
69*2c2f96dcSApple OSS Distributions
70*2c2f96dcSApple OSS Distributions if (-1 == waitpid(child_pid, &child_status, 0)) {
71*2c2f96dcSApple OSS Distributions T_FAIL("waitpid: child mia");
72*2c2f96dcSApple OSS Distributions }
73*2c2f96dcSApple OSS Distributions
74*2c2f96dcSApple OSS Distributions T_ASSERT_EQ(WIFEXITED(child_status), 0, "Child did not exit normally");
75*2c2f96dcSApple OSS Distributions
76*2c2f96dcSApple OSS Distributions if (WIFSIGNALED(child_status)) {
77*2c2f96dcSApple OSS Distributions T_ASSERT_EQ(child_status, 9, "Child exited with status = %x", child_status);
78*2c2f96dcSApple OSS Distributions }
79*2c2f96dcSApple OSS Distributions }
80*2c2f96dcSApple OSS Distributions
81*2c2f96dcSApple OSS Distributions typedef struct {
82*2c2f96dcSApple OSS Distributions mach_msg_header_t header;
83*2c2f96dcSApple OSS Distributions mach_msg_body_t body;
84*2c2f96dcSApple OSS Distributions mach_msg_port_descriptor_t port_descriptor;
85*2c2f96dcSApple OSS Distributions mach_msg_trailer_t trailer; // subtract this when sending
86*2c2f96dcSApple OSS Distributions } ipc_complex_message;
87*2c2f96dcSApple OSS Distributions
88*2c2f96dcSApple OSS Distributions struct args {
89*2c2f96dcSApple OSS Distributions const char *progname;
90*2c2f96dcSApple OSS Distributions int verbose;
91*2c2f96dcSApple OSS Distributions int voucher;
92*2c2f96dcSApple OSS Distributions int num_msgs;
93*2c2f96dcSApple OSS Distributions const char *server_port_name;
94*2c2f96dcSApple OSS Distributions mach_port_t server_port;
95*2c2f96dcSApple OSS Distributions mach_port_t reply_port;
96*2c2f96dcSApple OSS Distributions int request_msg_size;
97*2c2f96dcSApple OSS Distributions void *request_msg;
98*2c2f96dcSApple OSS Distributions int reply_msg_size;
99*2c2f96dcSApple OSS Distributions void *reply_msg;
100*2c2f96dcSApple OSS Distributions uint32_t persona_id;
101*2c2f96dcSApple OSS Distributions long client_pid;
102*2c2f96dcSApple OSS Distributions };
103*2c2f96dcSApple OSS Distributions
104*2c2f96dcSApple OSS Distributions void parse_args(struct args *args);
105*2c2f96dcSApple OSS Distributions void server_setup(struct args* args);
106*2c2f96dcSApple OSS Distributions void* exception_server_thread(void *arg);
107*2c2f96dcSApple OSS Distributions mach_port_t create_exception_port(void);
108*2c2f96dcSApple OSS Distributions static mach_port_t create_resource_notify_port(void);
109*2c2f96dcSApple OSS Distributions void server_run(struct args *args);
110*2c2f96dcSApple OSS Distributions static ipc_complex_message icm_request = {};
111*2c2f96dcSApple OSS Distributions static ipc_complex_message icm_reply = {};
112*2c2f96dcSApple OSS Distributions
113*2c2f96dcSApple OSS Distributions #define TEST_TIMEOUT 10
114*2c2f96dcSApple OSS Distributions
115*2c2f96dcSApple OSS Distributions void
parse_args(struct args * args)116*2c2f96dcSApple OSS Distributions parse_args(struct args *args)
117*2c2f96dcSApple OSS Distributions {
118*2c2f96dcSApple OSS Distributions args->server_port_name = "TEST_PORT_TABLE_LIMITS";
119*2c2f96dcSApple OSS Distributions args->server_port = MACH_PORT_NULL;
120*2c2f96dcSApple OSS Distributions args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
121*2c2f96dcSApple OSS Distributions args->request_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
122*2c2f96dcSApple OSS Distributions args->reply_msg_size = sizeof(ipc_complex_message) - sizeof(mach_msg_trailer_t);
123*2c2f96dcSApple OSS Distributions args->request_msg = &icm_request;
124*2c2f96dcSApple OSS Distributions args->reply_msg = &icm_reply;
125*2c2f96dcSApple OSS Distributions }
126*2c2f96dcSApple OSS Distributions
127*2c2f96dcSApple OSS Distributions /* Create a mach IPC listener which will respond to the client's message */
128*2c2f96dcSApple OSS Distributions void
server_setup(struct args * args)129*2c2f96dcSApple OSS Distributions server_setup(struct args *args)
130*2c2f96dcSApple OSS Distributions {
131*2c2f96dcSApple OSS Distributions kern_return_t ret;
132*2c2f96dcSApple OSS Distributions mach_port_t bsport;
133*2c2f96dcSApple OSS Distributions
134*2c2f96dcSApple OSS Distributions ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE,
135*2c2f96dcSApple OSS Distributions &args->server_port);
136*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_allocate()");
137*2c2f96dcSApple OSS Distributions
138*2c2f96dcSApple OSS Distributions ret = mach_port_insert_right(mach_task_self(), args->server_port, args->server_port,
139*2c2f96dcSApple OSS Distributions MACH_MSG_TYPE_MAKE_SEND);
140*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_port_insert_right()");
141*2c2f96dcSApple OSS Distributions
142*2c2f96dcSApple OSS Distributions ret = task_get_bootstrap_port(mach_task_self(), &bsport);
143*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: task_get_bootstrap_port()");
144*2c2f96dcSApple OSS Distributions
145*2c2f96dcSApple OSS Distributions ret = bootstrap_register(bsport, (const char *)args->server_port_name, args->server_port);
146*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: bootstrap_register()");
147*2c2f96dcSApple OSS Distributions
148*2c2f96dcSApple OSS Distributions T_LOG("server: waiting for IPC messages from client on port '%s'.\n",
149*2c2f96dcSApple OSS Distributions args->server_port_name);
150*2c2f96dcSApple OSS Distributions }
151*2c2f96dcSApple OSS Distributions
152*2c2f96dcSApple OSS Distributions void
server_run(struct args * args)153*2c2f96dcSApple OSS Distributions server_run(struct args *args)
154*2c2f96dcSApple OSS Distributions {
155*2c2f96dcSApple OSS Distributions mach_msg_header_t *request;
156*2c2f96dcSApple OSS Distributions mach_msg_option_t rcvoption;
157*2c2f96dcSApple OSS Distributions kern_return_t ret;
158*2c2f96dcSApple OSS Distributions mach_port_t dummy_port;
159*2c2f96dcSApple OSS Distributions mach_port_t client_task_port;
160*2c2f96dcSApple OSS Distributions
161*2c2f96dcSApple OSS Distributions request = (mach_msg_header_t *)args->request_msg;
162*2c2f96dcSApple OSS Distributions
163*2c2f96dcSApple OSS Distributions rcvoption = MACH_RCV_MSG | MACH_RCV_INTERRUPT;
164*2c2f96dcSApple OSS Distributions
165*2c2f96dcSApple OSS Distributions T_LOG("server: Awaiting message");
166*2c2f96dcSApple OSS Distributions ret = mach_msg(request,
167*2c2f96dcSApple OSS Distributions rcvoption,
168*2c2f96dcSApple OSS Distributions 0,
169*2c2f96dcSApple OSS Distributions sizeof(ipc_complex_message),
170*2c2f96dcSApple OSS Distributions args->server_port,
171*2c2f96dcSApple OSS Distributions MACH_MSG_TIMEOUT_NONE,
172*2c2f96dcSApple OSS Distributions MACH_PORT_NULL);
173*2c2f96dcSApple OSS Distributions
174*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_msg receive");
175*2c2f96dcSApple OSS Distributions
176*2c2f96dcSApple OSS Distributions int err = task_for_pid(mach_task_self(), (int)args->client_pid, &client_task_port);
177*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(err, "server: task_for_pid");
178*2c2f96dcSApple OSS Distributions ret = task_set_special_port(client_task_port, TASK_RESOURCE_NOTIFY_PORT, resource_notify_port);
179*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: task_set_special_port");
180*2c2f96dcSApple OSS Distributions
181*2c2f96dcSApple OSS Distributions //Sending reply message.
182*2c2f96dcSApple OSS Distributions T_LOG("server: Allocate dummy port\n");
183*2c2f96dcSApple OSS Distributions ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &dummy_port);
184*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: allocate dummy port");
185*2c2f96dcSApple OSS Distributions
186*2c2f96dcSApple OSS Distributions //Listen for the reply on the reply port
187*2c2f96dcSApple OSS Distributions T_LOG("server: Sending Reply\n");
188*2c2f96dcSApple OSS Distributions /* Construct the message */
189*2c2f96dcSApple OSS Distributions mach_msg_header_t *reply = (mach_msg_header_t *)args->reply_msg;
190*2c2f96dcSApple OSS Distributions reply->msgh_bits = MACH_MSGH_BITS_SET(MACH_MSG_TYPE_COPY_SEND, 0,
191*2c2f96dcSApple OSS Distributions 0, 0) | MACH_MSGH_BITS_COMPLEX;
192*2c2f96dcSApple OSS Distributions reply->msgh_size = (mach_msg_size_t)args->reply_msg_size;
193*2c2f96dcSApple OSS Distributions reply->msgh_remote_port = request->msgh_remote_port;
194*2c2f96dcSApple OSS Distributions reply->msgh_local_port = 0;
195*2c2f96dcSApple OSS Distributions reply->msgh_id = 2;
196*2c2f96dcSApple OSS Distributions
197*2c2f96dcSApple OSS Distributions ipc_complex_message *complexmsg = (ipc_complex_message *)reply;
198*2c2f96dcSApple OSS Distributions complexmsg->body.msgh_descriptor_count = 1;
199*2c2f96dcSApple OSS Distributions complexmsg->port_descriptor.name = dummy_port;
200*2c2f96dcSApple OSS Distributions complexmsg->port_descriptor.disposition = MACH_MSG_TYPE_MOVE_RECEIVE;
201*2c2f96dcSApple OSS Distributions complexmsg->port_descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
202*2c2f96dcSApple OSS Distributions
203*2c2f96dcSApple OSS Distributions mach_msg_option_t option = MACH_SEND_MSG;
204*2c2f96dcSApple OSS Distributions
205*2c2f96dcSApple OSS Distributions ret = mach_msg(reply,
206*2c2f96dcSApple OSS Distributions option,
207*2c2f96dcSApple OSS Distributions (mach_msg_size_t)args->reply_msg_size,
208*2c2f96dcSApple OSS Distributions 0,
209*2c2f96dcSApple OSS Distributions MACH_PORT_NULL,
210*2c2f96dcSApple OSS Distributions MACH_MSG_TIMEOUT_NONE,
211*2c2f96dcSApple OSS Distributions MACH_PORT_NULL);
212*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(ret, "server: mach_msg reply sent");
213*2c2f96dcSApple OSS Distributions }
214*2c2f96dcSApple OSS Distributions
215*2c2f96dcSApple OSS Distributions static mach_port_t
create_resource_notify_port()216*2c2f96dcSApple OSS Distributions create_resource_notify_port()
217*2c2f96dcSApple OSS Distributions {
218*2c2f96dcSApple OSS Distributions kern_return_t kret;
219*2c2f96dcSApple OSS Distributions mach_port_t rn_port = MACH_PORT_NULL;
220*2c2f96dcSApple OSS Distributions mach_port_t task = mach_task_self();
221*2c2f96dcSApple OSS Distributions
222*2c2f96dcSApple OSS Distributions kret = mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, &rn_port);
223*2c2f96dcSApple OSS Distributions T_EXPECT_MACH_SUCCESS(kret, "mach_port_allocate resource_notify_port");
224*2c2f96dcSApple OSS Distributions
225*2c2f96dcSApple OSS Distributions kret = mach_port_insert_right(task, rn_port, rn_port, MACH_MSG_TYPE_MAKE_SEND);
226*2c2f96dcSApple OSS Distributions T_EXPECT_MACH_SUCCESS(kret, "mach_port_insert_right resource_notify_port");
227*2c2f96dcSApple OSS Distributions
228*2c2f96dcSApple OSS Distributions return rn_port;
229*2c2f96dcSApple OSS Distributions }
230*2c2f96dcSApple OSS Distributions
231*2c2f96dcSApple OSS Distributions T_DECL(test_port_table_hard_limit_with_resource_notify_port,
232*2c2f96dcSApple OSS Distributions "Allocate ports upto hard limit and trigger notification",
233*2c2f96dcSApple OSS Distributions T_META_IGNORECRASHES(".*port_table_limits_client.*"),
234*2c2f96dcSApple OSS Distributions T_META_CHECK_LEAKS(false))
235*2c2f96dcSApple OSS Distributions {
236*2c2f96dcSApple OSS Distributions char *test_prog_name = "./port_table_limits_client";
237*2c2f96dcSApple OSS Distributions char *child_args[MAX_ARGV];
238*2c2f96dcSApple OSS Distributions int child_pid;
239*2c2f96dcSApple OSS Distributions posix_spawnattr_t attrs;
240*2c2f96dcSApple OSS Distributions int err;
241*2c2f96dcSApple OSS Distributions kern_return_t kr;
242*2c2f96dcSApple OSS Distributions struct args* server_args = (struct args*)malloc(sizeof(struct args));
243*2c2f96dcSApple OSS Distributions
244*2c2f96dcSApple OSS Distributions #if TARGET_OS_BRIDGE
245*2c2f96dcSApple OSS Distributions T_SKIP("Not running on target platforms");
246*2c2f96dcSApple OSS Distributions #endif
247*2c2f96dcSApple OSS Distributions
248*2c2f96dcSApple OSS Distributions /* Create the bootstrap port */
249*2c2f96dcSApple OSS Distributions parse_args(server_args);
250*2c2f96dcSApple OSS Distributions server_setup(server_args);
251*2c2f96dcSApple OSS Distributions
252*2c2f96dcSApple OSS Distributions /* Create the resource notify port for the server */
253*2c2f96dcSApple OSS Distributions mach_port_t rn_port = create_resource_notify_port();
254*2c2f96dcSApple OSS Distributions T_ASSERT_NE(rn_port, 0, "Create a new resource notify port");
255*2c2f96dcSApple OSS Distributions resource_notify_port = rn_port;
256*2c2f96dcSApple OSS Distributions
257*2c2f96dcSApple OSS Distributions /* Initialize posix_spawn attributes */
258*2c2f96dcSApple OSS Distributions posix_spawnattr_init(&attrs);
259*2c2f96dcSApple OSS Distributions err = posix_spawnattr_set_portlimits_ext(&attrs, 0, 7000);
260*2c2f96dcSApple OSS Distributions T_ASSERT_POSIX_SUCCESS(err, "posix_spawnattr_set_portlimits_ext");
261*2c2f96dcSApple OSS Distributions
262*2c2f96dcSApple OSS Distributions child_args[0] = test_prog_name;
263*2c2f96dcSApple OSS Distributions child_args[1] = "0"; // soft limit
264*2c2f96dcSApple OSS Distributions child_args[2] = "7000"; // hard limit
265*2c2f96dcSApple OSS Distributions child_args[3] = "2"; // test num
266*2c2f96dcSApple OSS Distributions child_args[4] = NULL;
267*2c2f96dcSApple OSS Distributions
268*2c2f96dcSApple OSS Distributions err = posix_spawn(&child_pid, child_args[0], NULL, &attrs, &child_args[0], environ);
269*2c2f96dcSApple OSS Distributions T_ASSERT_POSIX_SUCCESS(err, "posix_spawn port_table_limits_client");
270*2c2f96dcSApple OSS Distributions
271*2c2f96dcSApple OSS Distributions server_args->client_pid = child_pid;
272*2c2f96dcSApple OSS Distributions server_run(server_args);
273*2c2f96dcSApple OSS Distributions
274*2c2f96dcSApple OSS Distributions T_LOG("server: Let's see if we can catch some port leak");
275*2c2f96dcSApple OSS Distributions /*
276*2c2f96dcSApple OSS Distributions * Recover the service port because the port must have been destroyed and sent the notification by now
277*2c2f96dcSApple OSS Distributions */
278*2c2f96dcSApple OSS Distributions kr = mach_msg_server_once(resource_notify_server, 4096, resource_notify_port, 0);
279*2c2f96dcSApple OSS Distributions T_ASSERT_MACH_SUCCESS(kr, "mach_msg_server_once resource_notify_port");
280*2c2f96dcSApple OSS Distributions }
281*2c2f96dcSApple OSS Distributions
282*2c2f96dcSApple OSS Distributions // MIG's resource_notify_server() expects receive_cpu_usage_trigger()
283*2c2f96dcSApple OSS Distributions // This must match the definition in xnu's resource_notify.defs
284*2c2f96dcSApple OSS Distributions kern_return_t
receive_cpu_usage_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_nsecs,__unused int64_t observation_nsecs,__unused int64_t cpu_nsecs_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)285*2c2f96dcSApple OSS Distributions receive_cpu_usage_violation(__unused mach_port_t receiver,
286*2c2f96dcSApple OSS Distributions __unused proc_name_t procname,
287*2c2f96dcSApple OSS Distributions __unused pid_t pid,
288*2c2f96dcSApple OSS Distributions __unused posix_path_t killed_proc_path,
289*2c2f96dcSApple OSS Distributions __unused mach_timespec_t timestamp,
290*2c2f96dcSApple OSS Distributions __unused int64_t observed_cpu_nsecs,
291*2c2f96dcSApple OSS Distributions __unused int64_t observation_nsecs,
292*2c2f96dcSApple OSS Distributions __unused int64_t cpu_nsecs_allowed,
293*2c2f96dcSApple OSS Distributions __unused int64_t limit_window_nsecs,
294*2c2f96dcSApple OSS Distributions __unused resource_notify_flags_t flags)
295*2c2f96dcSApple OSS Distributions {
296*2c2f96dcSApple OSS Distributions T_LOG("Inside receive_cpu_usage_violation");
297*2c2f96dcSApple OSS Distributions return KERN_SUCCESS;
298*2c2f96dcSApple OSS Distributions }
299*2c2f96dcSApple OSS Distributions
300*2c2f96dcSApple OSS Distributions kern_return_t
receive_cpu_wakes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_cpu_wakes,__unused int64_t observation_nsecs,__unused int64_t cpu_wakes_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)301*2c2f96dcSApple OSS Distributions receive_cpu_wakes_violation(__unused mach_port_t receiver,
302*2c2f96dcSApple OSS Distributions __unused proc_name_t procname,
303*2c2f96dcSApple OSS Distributions __unused pid_t pid,
304*2c2f96dcSApple OSS Distributions __unused posix_path_t killed_proc_path,
305*2c2f96dcSApple OSS Distributions __unused mach_timespec_t timestamp,
306*2c2f96dcSApple OSS Distributions __unused int64_t observed_cpu_wakes,
307*2c2f96dcSApple OSS Distributions __unused int64_t observation_nsecs,
308*2c2f96dcSApple OSS Distributions __unused int64_t cpu_wakes_allowed,
309*2c2f96dcSApple OSS Distributions __unused int64_t limit_window_nsecs,
310*2c2f96dcSApple OSS Distributions __unused resource_notify_flags_t flags)
311*2c2f96dcSApple OSS Distributions {
312*2c2f96dcSApple OSS Distributions T_LOG("Inside receive_cpu_wakes_violation");
313*2c2f96dcSApple OSS Distributions return KERN_SUCCESS;
314*2c2f96dcSApple OSS Distributions }
315*2c2f96dcSApple OSS Distributions
316*2c2f96dcSApple OSS Distributions kern_return_t
receive_disk_writes_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused posix_path_t killed_proc_path,__unused mach_timespec_t timestamp,__unused int64_t observed_bytes_dirtied,__unused int64_t observation_nsecs,__unused int64_t bytes_dirtied_allowed,__unused int64_t limit_window_nsecs,__unused resource_notify_flags_t flags)317*2c2f96dcSApple OSS Distributions receive_disk_writes_violation(__unused mach_port_t receiver,
318*2c2f96dcSApple OSS Distributions __unused proc_name_t procname,
319*2c2f96dcSApple OSS Distributions __unused pid_t pid,
320*2c2f96dcSApple OSS Distributions __unused posix_path_t killed_proc_path,
321*2c2f96dcSApple OSS Distributions __unused mach_timespec_t timestamp,
322*2c2f96dcSApple OSS Distributions __unused int64_t observed_bytes_dirtied,
323*2c2f96dcSApple OSS Distributions __unused int64_t observation_nsecs,
324*2c2f96dcSApple OSS Distributions __unused int64_t bytes_dirtied_allowed,
325*2c2f96dcSApple OSS Distributions __unused int64_t limit_window_nsecs,
326*2c2f96dcSApple OSS Distributions __unused resource_notify_flags_t flags)
327*2c2f96dcSApple OSS Distributions {
328*2c2f96dcSApple OSS Distributions return KERN_SUCCESS;
329*2c2f96dcSApple OSS Distributions }
330*2c2f96dcSApple OSS Distributions
331*2c2f96dcSApple OSS Distributions kern_return_t
receive_port_space_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,int64_t observed_ports,int64_t ports_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)332*2c2f96dcSApple OSS Distributions receive_port_space_violation(__unused mach_port_t receiver,
333*2c2f96dcSApple OSS Distributions __unused proc_name_t procname,
334*2c2f96dcSApple OSS Distributions __unused pid_t pid,
335*2c2f96dcSApple OSS Distributions __unused mach_timespec_t timestamp,
336*2c2f96dcSApple OSS Distributions int64_t observed_ports,
337*2c2f96dcSApple OSS Distributions int64_t ports_allowed,
338*2c2f96dcSApple OSS Distributions __unused mach_port_t fatal_port,
339*2c2f96dcSApple OSS Distributions __unused resource_notify_flags_t flags)
340*2c2f96dcSApple OSS Distributions {
341*2c2f96dcSApple OSS Distributions T_LOG("Received a notification on the resource notify port");
342*2c2f96dcSApple OSS Distributions T_LOG("Ports_allowed = %lld, observed_ports = %lld", ports_allowed, observed_ports);
343*2c2f96dcSApple OSS Distributions if (fatal_port) {
344*2c2f96dcSApple OSS Distributions mach_port_deallocate(mach_task_self(), fatal_port);
345*2c2f96dcSApple OSS Distributions }
346*2c2f96dcSApple OSS Distributions return KERN_SUCCESS;
347*2c2f96dcSApple OSS Distributions }
348*2c2f96dcSApple OSS Distributions
349*2c2f96dcSApple OSS Distributions kern_return_t
receive_file_descriptors_violation(__unused mach_port_t receiver,__unused proc_name_t procname,__unused pid_t pid,__unused mach_timespec_t timestamp,__unused int64_t observed_filedesc,__unused int64_t filedesc_allowed,__unused mach_port_t fatal_port,__unused resource_notify_flags_t flags)350*2c2f96dcSApple OSS Distributions receive_file_descriptors_violation(__unused mach_port_t receiver,
351*2c2f96dcSApple OSS Distributions __unused proc_name_t procname,
352*2c2f96dcSApple OSS Distributions __unused pid_t pid,
353*2c2f96dcSApple OSS Distributions __unused mach_timespec_t timestamp,
354*2c2f96dcSApple OSS Distributions __unused int64_t observed_filedesc,
355*2c2f96dcSApple OSS Distributions __unused int64_t filedesc_allowed,
356*2c2f96dcSApple OSS Distributions __unused mach_port_t fatal_port,
357*2c2f96dcSApple OSS Distributions __unused resource_notify_flags_t flags)
358*2c2f96dcSApple OSS Distributions {
359*2c2f96dcSApple OSS Distributions return KERN_SUCCESS;
360*2c2f96dcSApple OSS Distributions }
361